Skip to content

test: make JSON tests independent of the JSON backend's error details - #1428

Merged
zeroshade merged 1 commit into
apache:mainfrom
zeroshade:fix-json-backend-tests
Oct 27, 2026
Merged

zeroshade merged 1 commit into
apache:mainfrom
zeroshade:fix-json-backend-tests

Conversation

@zeroshade

Copy link
Copy Markdown
Member

Rationale for this change

The Dependabot bump of github.com/goccy/go-json to v0.11.2 (#1357) fails CI. go-json 0.11 is stricter and follows encoding/json's behaviour for the Go version it is built with, which exposed three tests that depended on lenient parsing or on backend-specific error details:

  • arrow/compute TestIsInDecimal: the expected array literal is [true, false true] (missing comma); go-json 0.10 accepted it.
  • arrow/array TestIntegerArrsJSON and TestRecordBuilderUnmarshalOneReturnUnexpectedEOF: under Go 1.27's v2 JSON semantics, truncated input is reported as a syntax error ("unexpected end of JSON input") instead of io.ErrUnexpectedEOF.
  • parquet/variant TestBuilderJSONErrors: the error message depends on which tokenizer call first notices the malformed input.

The last two already fail on main with the standard-library backend (-tags arrow_json_stdlib, also used for TinyGo) under Go 1.27, independent of the bump.

What changes are included in this PR?

Test-only:

  • Fix the JSON literal in TestIsInDecimal.
  • A helper assertTruncatedJSONError checks that truncated input is an error and not a clean io.EOF — the invariant fix(array/record): bldr stop ignore unexpected EOF #1341 added — while accepting either io.ErrUnexpectedEOF or an "unexpected end of JSON input" syntax error.
  • TestBuilderJSONErrors keeps all its malformed inputs but only checks that ParseJSON rejects them.

Are these changes tested?

The affected packages (arrow/array, arrow/compute, parquet/variant) pass with Go 1.26 and Go 1.27, each with go-json v0.10.6, go-json v0.11.2 and -tags arrow_json_stdlib. Disabling the io.EOF → io.ErrUnexpectedEOF conversion in RecordBuilder.unmarshalOne still fails TestRecordBuilderUnmarshalOneReturnUnexpectedEOF ("truncated input must not be reported as a clean EOF").

Are there any user-facing changes?

No.

- arrow/compute: TestIsInDecimal's expected array was `[true, false true]`
  (missing comma), which only parsed because go-json 0.10 was lenient.
- arrow/array: truncated input is reported as io.ErrUnexpectedEOF by
  encoding/json before Go 1.27's v2 semantics and by go-json before 0.11,
  but as a syntax error ("unexpected end of JSON input") otherwise. Assert
  that truncation is an error and not a clean io.EOF (the apache#1341
  invariant), accepting either form.
- parquet/variant: TestBuilderJSONErrors pinned messages from whichever
  internal branch the tokenizer happened to reach; check only that
  ParseJSON rejects the input.

These failed on main with -tags arrow_json_stdlib under Go 1.27, and fail
with github.com/goccy/go-json v0.11.2 (apache#1357).
@zeroshade
zeroshade merged commit c0d32bd into apache:main Oct 27, 2026
23 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.

1 participant