cog
b43abeae - fix: replace deprecated library usage patterns (#2798)

Commit
1 day ago
fix: replace deprecated library usage patterns (#2798) * fix: replace deprecated github.com/pkg/errors with fmt.Errorf The pkg/errors package is deprecated. Replace errors.Errorf() calls in pkg/docker/build_secrets.go with fmt.Errorf(), which is a direct drop-in since no error wrapping with %w was used. This removes the direct dependency on pkg/errors (it remains as an indirect dep of other packages). * fix: replace os.IsNotExist() with errors.Is(err, os.ErrNotExist) os.IsNotExist() does not unwrap error chains, which means it can miss wrapped os.ErrNotExist errors. errors.Is() correctly traverses the error chain and is the recommended approach since Go 1.13. Affected files: - pkg/image/build.go (2 occurrences) - pkg/cli/predict.go - pkg/config/validate.go - pkg/model/weight_builder.go - pkg/util/files/files.go * fix: replace direct error comparison with errors.Is() for ErrMissingDeviceDriver Direct err == sentinel comparison does not unwrap error chains. Use errors.Is() for consistent and correct sentinel error checking, matching the pattern already used in pkg/cli/predict.go. Affected files: - pkg/cli/run.go - pkg/cli/serve.go - pkg/image/openapi_schema.go * fix: replace http.Get/http.PostForm with context-aware requests http.Get() and http.PostForm() create requests without a context, making them impossible to cancel and susceptible to hanging indefinitely. Use http.NewRequestWithContext() + client.Do() instead. - pkg/predict/predictor.go: GetSchema() now uses context.Background() - pkg/provider/replicate/replicate.go: getDisplayTokenURL() and verifyToken() now accept and propagate context from their callers --------- Co-authored-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Author
Parents
Loading