#212

fix(testing): preserve recorded JSON null values

Opensdivyanshu90wants to merge intofrom

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 test run.
  • deno task check, deno task lint, changed-file deno fmt --check, git diff --check, and deno task version:check --base upstream/main pass.

@ooctoo777, could you review and merge this fix?

Summary by CodeRabbit

  • Bug Fixes
    • Recorded and replayed responses now preserve JSON null as 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-padded null.

Activity

2
coderabbitai[bot]4d ago

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 09d54479142e36eff876383beacfbd37b33b5908 and 4224dfabdc382f4c33ab0a4fb413024e0c306c8c.

Files selected for processing: 2
  • shared/testing/fixture-size.test.ts
  • shared/testing/fixtures.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Walkthrough

recordingFetch now retains JSON null as 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 4224d

The change preserves recorded JSON null values. No merge-blocking issue is established.

Pre-merge checks: 4
Check nameStatusExplanation
Description CheckCheck skipped - CodeRabbit’s high-level summary is enabled.
Title checkThe title clearly and concisely describes the main change: preserving recorded JSON null values during testing.
Linked Issues checkIssue #210 requires 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 …
Out of Scope Changes checkThe changes are limited to the recording fallback in shared/testing/fixtures.ts and regression coverage in shared/testing/fixture-size.test.ts. Both changes directly support issue #210.
Full details: Linked Issues check

Explanation

Issue #210 requires 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 now falls back only when parsedBody === undefined. shared/testing/fixture-size.test.ts covers null, whitespace-padded null, the string "null", scalars, nested nulls, plain text, live text, and replay.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.