Skip to content

fix(browser): keep omitted JSON request bodies out of complete shape coverage - #4476

Merged
morluto merged 1 commit into
morluto:mainfrom
Adolanium:fix/json-body-shape-coverage
Oct 22, 2026
Merged

morluto merged 1 commit into
morluto:mainfrom
Adolanium:fix/json-body-shape-coverage

Conversation

@Adolanium

@Adolanium Adolanium commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #4477.

With include_json_body_shapes, a JSON request whose body CDP did not deliver was recorded as complete once its response shape arrived. Two identical captures of such a request compared as unchanged instead of unknown.

Problem and expected behavior

docs/browser-observation.md says unavailable or truncated selected coverage makes equivalence unknown.

CDP sets hasPostData: true and omits postData when a request body is long. requestBodyShape in src/browser/CdpCaptureEventBodyShapes.ts returned status: "unavailable" for that request without marking json_body_shapes unavailable. updateResponseBodyShape then set status: "included" with request: null as soon as a JSON response shape arrived. networkDimension in src/domain/webCaptureDiff.ts treats included plus a complete json_body_shapes section as full coverage, so the comparison reported unchanged. hasPostData was not read anywhere in src/. An unparseable JSON request body had the same upgrade to included, although that case already marked the section unavailable.

Change and scope

requestBodyShape now records a request in missingRequestBodyShapeIds and marks json_body_shapes unavailable when a JSON request-body shape was expected but not obtained:

  • hasPostData: true without postData, and the content type is JSON;
  • postData with a JSON content type that does not parse.

updateResponseBodyShape reports such a request as partial instead of included when the response shape arrives. The set is reset on each requestWillBeSent for the request ID and cleared in beginAuthorizedFrame.

A request without a body (no postData, no hasPostData) keeps today's behavior, including a GET that sends a JSON Content-Type. A request with an omitted body and a non-JSON or absent content type, such as a form post, is also unchanged, because only JSON media types are read. This matches the existing handling of an inline body without a JSON content type.

docs/browser-observation.md now states that such a JSON-typed request is partial and makes json_body_shapes unavailable.

Scope: not applicable. This is a fix within the existing passive capture boundary.

Contract and boundary impact

  • Semantic owner and earliest changed stage: CDP passive capture, request body-shape projection in requestBodyShape.
  • Contribution scope fit and linked maintainer decision: ordinary fix within existing boundaries; not applicable.
  • CLI and MCP/tool-catalog contract: no schema change. body_shapes.status uses the existing partial value for these requests, and completeness.unavailable_sections gains json_body_shapes.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: a capture no longer claims complete JSON body-shape coverage for a request whose body shape was not observed. compare_web_captures reports unknown for such captures.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: tests/boundary/browser/cdpJsonShapeComparison.test.ts feeds CDP events through CdpCaptureEvents and compares the captures through compareWebCaptureEvidence. It covers an omitted JSON body and an unparseable JSON body (both partial, section unavailable, comparison unknown). It also covers a bodiless GET, a bodiless GET with a JSON Content-Type, an omitted body without a media type, and an omitted form body (all included, comparison unchanged).
  • Base reproduction or other evidence: executed on upstream/main (8ab502439) with the same test helper. For hasPostData: true, JSON Content-Type, no postData, and a JSON response, the request had body_shapes.status: "included", unavailable_sections was [], and the network dimension was unchanged. The two new partial cases failed on the base; the four unchanged-behavior cases passed.
  • User-visible CLI/MCP output (if applicable): "body_shapes": { "status": "partial", "request": null, "response": { ... } } and json_body_shapes in completeness.unavailable_sections for such a request.
  • Remaining proof gaps: no live Chromium capture with a long request body was run. The events follow the CDP Network.Request shape (hasPostData, postData).

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npx vitest run tests/boundary/browser/cdpJsonShapeComparison.test.ts src/browser/CdpCaptureEvents.redirectBodyShape.test.ts tests/boundary/browser/cdpBrowserProvider.network.test.ts tests/boundary/browser/cdpBrowserProvider.redirectErrors.test.ts tests/boundary/browser/cdpBrowserProvider.sensitive_data.test.ts src/domain/webCaptureDiff.network.test.ts tests/boundary/mcp/browserComparisonInput.test.ts — 7 files, 119 tests passed.
  • npx vitest run tests/boundary/browser/cdpJsonShapeComparison.test.ts with src/browser restored from 8ab502439 — 2 failed (the omitted and unparseable JSON body cases), 42 passed.
  • npx tsc --noEmit --pretty false — no errors.
  • npx oxlint on the five changed source and test files — 0 errors; 3 existing size and complexity warnings in CdpCaptureEventHandlers.ts.
  • npx oxfmt --check on the changed files and docs/browser-observation.md — all files correctly formatted.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Captures with an omitted or unparseable JSON request body now report partial and an unavailable json_body_shapes section, so comparisons that reported unchanged for them now report unknown.
  • Real Hopper/Ghidra, browser, or OS coverage: not run.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: no new data is read or retained. hasPostData is a boolean already present in the CDP event.

Author readiness

Human owner: @Adolanium

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@Adolanium
Adolanium marked this pull request as ready for review October 16, 2026 13:16
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T13:20:25.173442Z bf33c6f Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable defects were found.

Summary

Fixes JSON body-shape coverage when CDP omits a request body or the body cannot be parsed.

  • Missing JSON request shapes keep response captures marked partial.

Review limits: tests were inspected, not rerun. Checking whether another PR supersedes this one was blocked because GitHub authentication was unavailable.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[JSON request body expected] --> B{Shape obtained?}
  B -->|No| C[Mark JSON coverage unavailable]
  C --> D[Response shape arrives]
  D --> E[Keep request partial]
  E --> F[Matching captures compare as unknown]
Loading

Reviews (1) · Last reviewed commit: "fix(browser): keep omitted JSON request ..." · Reviewed by Greptile

@morluto
morluto merged commit 7e8ec0e into morluto:main Oct 22, 2026
63 of 67 checks passed
@morluto morluto mentioned this pull request Oct 25, 2026
3 tasks done
@Adolanium
Adolanium deleted the fix/json-body-shape-coverage branch October 25, 2026 04:23
@morluto morluto added bug Something isn't working area: runtime Process capture and runtime observation labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Omitted JSON request bodies are reported as complete body-shape coverage

2 participants