#212
fix(testing): preserve recorded JSON null values
Fixes #210.
I preserved successfully parsed JSON null when recording response bodies. Previously the nullish fallback replaced null with its source text, so a replay delivered the string "null" instead of the value seen during recording. Only an undefined parse result now falls back to text.
The regression covers null (including surrounding whitespace), the JSON string "null", other JSON scalars, nested nulls, and non-JSON text through recording and replay, and checks that the relayed live text is preserved.
Validation (Deno 2.9.7):
- Regression fails before the fix; fixture suite: 11 passed, 0 failed.
- All 251 test modules imported into one temporary shared-process entry point: 1,299 passed, 0 failed, 221 gated live tests ignored. This is not a standard isolated-module
deno task testrun. deno task check,deno task lint, changed-filedeno fmt --check,git diff --check, anddeno task version:check --base upstream/mainpass.
@ooctoo777, could you review and merge this fix?
Summary by CodeRabbit
- Bug Fixes
- Recorded and replayed responses now preserve JSON
nullas a JSON value instead of converting it to text. Plain-text responses remain unchanged. - Response handling is verified across JSON values, including strings, numbers, booleans, objects, arrays, and
null, as well as plain text and whitespace-paddednull.
- Recorded and replayed responses now preserve JSON
No actionable comments were generated in the recent review.
95f19b69-bbea-4297-b052-893fb45dca8dReviewing files that changed from the base of the PR and between 09d54479142e36eff876383beacfbd37b33b5908 and 4224dfabdc382f4c33ab0a4fb413024e0c306c8c.
shared/testing/fixture-size.test.tsshared/testing/fixtures.tsIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
Walkthrough
recordingFetchnow retains JSONnullas the recorded response body. Tests check live response text, recorded values, and replayed JSON for null and other JSON values, plus plain text.Fixed issue severity: <fixed_issue_severity>Medium</fixed_issue_severity>
Priority: Low
Merge Risk: Minimal · up to
4224dThe change preserves recorded JSON null values. No merge-blocking issue is established.
Pre-merge checks: 4
#210requires recording valid JSON null as null, preserving the JSON string "null", retaining other JSON values, and falling back to source text for non-JSON input.shared/testing/fixtures.ts…shared/testing/fixtures.tsand regression coverage inshared/testing/fixture-size.test.ts. Both changes directly support issue#210.Full details: Linked Issues check
Explanation
Issue
#210requires recording valid JSON null as null, preserving the JSON string "null", retaining other JSON values, and falling back to source text for non-JSON input.shared/testing/fixtures.tsnow falls back only whenparsedBody === undefined.shared/testing/fixture-size.test.tscovers null, whitespace-padded null, the string "null", scalars, nested nulls, plain text, live text, and replay.Comment
@coderabbitai helpto get the list of available commands.