fix: wrap the Parse error in UUID.Scan with %w - #229
Open
januththedev wants to merge 2 commits into
Open
januththedev wants to merge 2 commits into
januththedev wants to merge 2 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
januththedev
force-pushed
the
fix/scan-error-wrap
branch
from
October 3, 2026 04:13
e884d19 to
cbc4051
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
UUID.Scanflattened theParseerror with%v, discarding its identity soerrors.Is/errors.Ascould not classify it.PR #166 (shipped in v1.6.0) added
ErrInvalidLength,ErrInvalidUUIDFormat,ErrInvalidURNPrefix,ErrInvalidBracketedFormatandIsInvalidLengthError()specifically so callers could useerrors.Is, and it wrappedParse,ParseBytesandValidatewith%w.UUID.Scan— the primary entry point for reading UUIDs out of a SQL driver — was missed, andsql.go:29is the onlyfmt.Errorfin the package that flattens a real error. The[]bytebranch recurses into the string branch, so it is affected too, as isNullUUID.Scanwhich delegates.Note the error text was already correct. Only the error type was lost, which is why this has gone unnoticed.
Reproduction
The change
Tests
TestScanErrorWrappingis table-driven with six subtests covering string and[]byteinputs for all three error types. Each asserts both thaterrors.Isnow matches the sentinel and that the message text is byte-identical to before, which is what demonstrates the change is non-breaking.go test -count=1 ./...→ 0 failures, 173 subtests passing.go vet ./...clean.The only formatting note is that
gofmt -lflags most files in this checkout, which is pre-existing CRLF line endings from Windows; a pristine clone produces the identical list.