Open
Conversation
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).
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
…eviceDriver 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
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
b76390f to
6e57523
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
github.com/pkg/errorswithfmt.Errorfinpkg/docker/build_secrets.goos.IsNotExist()witherrors.Is(err, os.ErrNotExist)across 6 call sites —os.IsNotExistdoesn't unwrap error chainserr == sentinelcomparison witherrors.Is()forErrMissingDeviceDriverin 3 files, matching the pattern already used inpkg/cli/predict.gohttp.Get()/http.PostForm()withhttp.NewRequestWithContext()+client.Do()— the convenience functions create requests without a context, making them impossible to cancelEach fix is in a separate commit for easy review.