Repository navigation
fix(browser): keep omitted JSON request bodies out of complete shape coverage - #4476
Merged
Merged
Conversation
2 tasks done
Adolanium
marked this pull request as ready for review
October 16, 2026 13:16
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
[Medium impact] The PR appears safe to merge; no actionable defects were found. SummaryFixes JSON body-shape coverage when CDP omits a request body or the body cannot be parsed.
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]
Reviews (1) · Last reviewed commit: "fix(browser): keep omitted JSON request ..." · Reviewed by Greptile |
17 of 22 tasks
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 asunchangedinstead ofunknown.Problem and expected behavior
docs/browser-observation.mdsays unavailable or truncated selected coverage makes equivalence unknown.CDP sets
hasPostData: trueand omitspostDatawhen a request body is long.requestBodyShapeinsrc/browser/CdpCaptureEventBodyShapes.tsreturnedstatus: "unavailable"for that request without markingjson_body_shapesunavailable.updateResponseBodyShapethen setstatus: "included"withrequest: nullas soon as a JSON response shape arrived.networkDimensioninsrc/domain/webCaptureDiff.tstreatsincludedplus a completejson_body_shapessection as full coverage, so the comparison reportedunchanged.hasPostDatawas not read anywhere insrc/. An unparseable JSON request body had the same upgrade toincluded, although that case already marked the section unavailable.Change and scope
requestBodyShapenow records a request inmissingRequestBodyShapeIdsand marksjson_body_shapesunavailable when a JSON request-body shape was expected but not obtained:hasPostData: truewithoutpostData, and the content type is JSON;postDatawith a JSON content type that does not parse.updateResponseBodyShapereports such a request aspartialinstead ofincludedwhen the response shape arrives. The set is reset on eachrequestWillBeSentfor the request ID and cleared inbeginAuthorizedFrame.A request without a body (no
postData, nohasPostData) keeps today's behavior, including a GET that sends a JSONContent-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.mdnow states that such a JSON-typed request ispartialand makesjson_body_shapesunavailable.Scope: not applicable. This is a fix within the existing passive capture boundary.
Contract and boundary impact
requestBodyShape.body_shapes.statususes the existingpartialvalue for these requests, andcompleteness.unavailable_sectionsgainsjson_body_shapes.compare_web_capturesreportsunknownfor such captures.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.
Evidence and regression coverage
tests/boundary/browser/cdpJsonShapeComparison.test.tsfeeds CDP events throughCdpCaptureEventsand compares the captures throughcompareWebCaptureEvidence. It covers an omitted JSON body and an unparseable JSON body (bothpartial, section unavailable, comparisonunknown). It also covers a bodiless GET, a bodiless GET with a JSONContent-Type, an omitted body without a media type, and an omitted form body (allincluded, comparisonunchanged).upstream/main(8ab502439) with the same test helper. ForhasPostData: true, JSONContent-Type, nopostData, and a JSON response, the request hadbody_shapes.status: "included",unavailable_sectionswas[], and the network dimension wasunchanged. The two newpartialcases failed on the base; the four unchanged-behavior cases passed."body_shapes": { "status": "partial", "request": null, "response": { ... } }andjson_body_shapesincompleteness.unavailable_sectionsfor such a request.Network.Requestshape (hasPostData,postData).For evidence-bearing changes:
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.tswithsrc/browserrestored from8ab502439— 2 failed (the omitted and unparseable JSON body cases), 42 passed.npx tsc --noEmit --pretty false— no errors.npx oxlinton the five changed source and test files — 0 errors; 3 existing size and complexity warnings inCdpCaptureEventHandlers.ts.npx oxfmt --checkon the changed files anddocs/browser-observation.md— all files correctly formatted.Compatibility, safety, and release
partialand an unavailablejson_body_shapessection, so comparisons that reportedunchangedfor them now reportunknown.hasPostDatais a boolean already present in the CDP event.Author readiness
Human owner: @Adolanium
Before merge
type(scope): outcome.