Skip to content

Fix JSON blob test error comparison on Go 1.27 - #756

Merged
jbelkins merged 2 commits into
mainfrom
fix/json-blob-test-go1.27
Nov 25, 2026
Merged

jbelkins merged 2 commits into
mainfrom
fix/json-blob-test-go1.27

Conversation

@jbelkins

Copy link
Copy Markdown
Contributor

Problem

TestReadBlob and FuzzReadBlob (added in #730) fail on Go 1.27 for every invalid-input case:

blob_test.go:36: unexpected error context: decode base64 blob: illegal base64 data at input byte 2

checkReadBlob expects the ReadBlob error text to be "decode base64 blob: " + <encoding/json error>. On Go 1.27, encoding/json puts its own prefix in front of the base64 error:

json: cannot unmarshal string into Go value of type []uint8: illegal base64 data at input byte 2

ReadBlob wraps only the base64.CorruptInputError, so the exact-text comparison no longer holds. The error type and offset checks still pass. CI covers Go 1.24–1.26, so this didn't show up there, but it breaks builds that use Go 1.27.

Fix

Compare the error text against the base64.CorruptInputError the test already extracts, which is the error ReadBlob actually wraps. This holds on every Go version. The test still checks that the error is a CorruptInputError at the same offset as the standard library's.

Test-only change. No changelog entry.

Testing

go test ./transport/http/protocol/internal/json/ passes on Go 1.27.4. It failed before this change.

checkReadBlob compared the ReadBlob error text against the encoding/json
error. Go 1.27 wraps the base64 error in a "json: cannot unmarshal"
message, so TestReadBlob and FuzzReadBlob fail on invalid input even though
the error and offset match. Compare against the base64.CorruptInputError
instead, which is the error ReadBlob wraps.
@jbelkins
jbelkins requested review from a team as code owners November 25, 2026 15:26
@jbelkins
jbelkins merged commit 54a5320 into main Nov 25, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants