Skip to content

fix(conformance): count an array with only null elements as unchecked - #336

Merged
bpauli merged 1 commit into
mainfrom
fix/335-null-array-unchecked
Nov 4, 2026
Merged

bpauli merged 1 commit into
mainfrom
fix/335-null-array-unchecked

Conversation

@bpauli

@bpauli bpauli commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Fixes #335.

Problem

The replay check logs a route as unchecked when no recording has an element at a path (#334). arrayOf.check marked a path as filled as soon as the array was not empty, and then skipped each null element. The scrub turns an all-null array into [null]. So a route whose recordings held only null elements passed with no unchecked line, and no element shape was checked.

Change

  • conformance/replay_test.go: arrayOf.check adds a path to filled only when it checked a non-null element there. Otherwise it adds the path to empty. An empty array and an all-null array now take the same path.
  • TestCheckShape has two new cases: [null, null] and a nested array of only nulls.
  • TestCaseProblemsEmptyArrays has two new cases: a [null] recording alone (unchecked line logged) and next to a recording with an element (no line).
  • conformance/README.md: the empty-array rule now names arrays that hold only null.

No command and no CLI output change, so the CHANGELOG does not change.

Verification

  • The gate passes: make fmt-check, make lint, go vet -tags e2e ./..., make test, make conformance.
  • With the arrayOf.check of main and the new tests, TestCheckShape fails on both new cases and TestCaseProblemsEmptyArrays fails on the [null] case.
  • The repro from conformance: an all-null array counts as filled, so the replay logs no unchecked line #335: the committed set with the favorites body set to [null], scrubbed with conformance/cmd/scrub and replayed with the command of the e2e replay step. On main the run prints only PASS and ok. On this branch it also prints the unchecked line for GET connectapi.garmin.com/course-service/course/favorites at (body) from both tests.
  • The committed set replays with -v and logs no unchecked line, the same as on main.

arrayOf.check marked a path as filled when the array was not empty, and
then skipped each null element. The scrub turns an all-null array into
[null], so a route whose recordings held only null elements passed with
no unchecked line and no element shape checked.

Mark a path as filled only when a non-null element there was checked.
Otherwise report it as empty.

Fixes #335
@bpauli

bpauli commented Nov 4, 2026

Copy link
Copy Markdown
Owner Author

Independent verification: PASS+NOTES

Head: 59b7ffd94dea1075034157d35ff4161d46d04dd2. Base: a995af21a6607f69c3bcf0590d72cfa5a3353488. I checked out each SHA in its own worktree.

Gate on head. make fmt-check, make lint (GOTOOLCHAIN=go1.26.0, 0 issues), go vet -tags e2e ./..., make test and make build && make conformance GCCLI_BIN=bin/gccli all pass. CI on the head is green (conformance, darwin-cgo-build, test).

1. arrayOf.check (conformance/replay_test.go:109). The loop that collects problems did not change, so a problem cannot depend on empty or filled. I ran checkShape on base and head for 88 inputs (4 shapes, 22 bodies: [], [null], [null,null], [null,{}], [{},null], [{"laps":null}], {"laps":null}, nested empty arrays, nested all-null arrays, mixed arrays, scalar arrays, wrong kinds, arrayOf{}). The problems column is the same in all 88 rows. Only the rows where every element of an array is null changed, from filled to empty. The empty array, the nested empty array, the mixed arrays and the null array value ({"laps": null}, neither empty nor filled) are the same as on base.

2. Repro from #335. I used the committed set, set the courses favorites body to [null], ran go run ./conformance/cmd/scrub (the output is [null]) and replayed it with the command of the e2e replay step (-v -run TestRecorded). Base: exit 0, no unchecked line. Head: exit 0, and GET connectapi.garmin.com/course-service/course/favorites: no recording has an element at (body), so the shape of its elements is unchecked under TestRecordedShapes/courses_favorites (replay_test.go:543) and TestRecordedReplay/courses_favorites (replay_test.go:772). The unchanged committed set replays with -v on base and head with exit 0, no unchecked line and the same list of subtests.

3. Injected defects (each reverted, git status clean after):

  • Always mark filled (if checked || true): TestCheckShape and TestCaseProblemsEmptyArrays fail.
  • Drop the else branch: both fail.
  • Mark filled on a null element (checked = true before the nil check): both fail on the new cases.
  • The rule of base (checked := len(arr) > 0): both fail on the new cases.
  • Mark the path empty and filled together: TestCheckShape fails.
  • A null element sets checked = false (last null wins, so [{}, null] is empty): no test fails, including the full conformance package with GCCLI_BIN.

4. README (conformance/README.md:101). The text says that an array that is empty or holds only null is not a problem, and that the route is logged when no recording has an element other than null at the path. This agrees with the code and with the repro.

5. CHANGELOG. The diff changes only conformance/README.md and conformance/replay_test.go. No command or CLI output changes, so no entry is necessary.

Notes (no change necessary for this PR):

  • No test has an array that holds null and an element together, so the last injected defect survives. The data cannot reach it. The scrub merges [null, {...}, null] into one object element (I checked this), so a scrubbed recording never holds such an array. A TestCheckShape case with [{"laps": [{}, null]}] would pin it if you want it.
  • This gap is older than the PR. A defect that stops the loop at the first null element, and so skips the shape check of later elements, also passes the full conformance package on base. The scrub also makes this unreachable.
  • Not related to this PR: a second scrub of the committed set renames get_userprofile-service.userprofile.settings_200_ad84095e.json to ..._4174016c.json on base and on head. The content is the same JSON with a different byte form.

@bpauli
bpauli merged commit 875691f into main Nov 4, 2026
3 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.

conformance: an all-null array counts as filled, so the replay logs no unchecked line

1 participant