Repository navigation
fix(browser): record malformed optional CDP replies as section gaps - #10657
Merged
Merged
Conversation
Codex Review Summary: ✅ CompletedThis 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 blocking issue was found. SummaryThis PR moves optional CDP reply checks into shared schemas and records malformed replies as gaps in the sections that read them.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[CDP reply] --> B[Shared reply schema]
B -->|Valid| C[Section reads entries]
B -->|Malformed optional reply| D[Record section gap]
C --> E[Capture with coverage limits]
D --> E
F[Transport or cancellation error] --> G[Propagate error]
Reviews (2) · Last reviewed commit: "Merge remote-tracking branch 'origin/ref..." · Reviewed by Greptile |
19 tasks
morluto
force-pushed
the
refactor/typed-cdp-optional-commands
branch
from
November 15, 2026 00:27
9852502 to
2b4857a
Compare
morluto
force-pushed
the
refactor/typed-cdp-optional-malformed
branch
from
November 15, 2026 00:27
a2ec940 to
3098f02
Compare
morluto
force-pushed
the
refactor/typed-cdp-optional-commands
branch
from
November 15, 2026 01:45
2b4857a to
8f0d6c5
Compare
morluto
force-pushed
the
refactor/typed-cdp-optional-malformed
branch
from
November 15, 2026 01:45
3098f02 to
3f55dc4
Compare
Base automatically changed from
refactor/typed-cdp-optional-commands
to
main
November 15, 2026 02:11
morluto
force-pushed
the
refactor/typed-cdp-optional-malformed
branch
from
November 15, 2026 02:20
3f55dc4 to
dc0e007
Compare
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
Sixth slice of typed CDP command replies, stacked on #10647 (base branch
refactor/typed-cdp-optional-commands; retarget as the stack below merges).optionalCdpCommandnow returnsResult<reply, CdpOptionalCommandGap>:CdpCommandUnavailable("method not found", as before) orCdpMalformedReply(the reply failed its registered result schema). Each caller records the gap in its own section; transport and cancellation failures still propagate.Storage.getUsageAndQuota,DOMStorage.getDOMStorageItems,IndexedDB.requestDatabaseNames/requestDatabase/requestData,CacheStorage.requestCacheNames/requestEntries/requestCachedResponse,Network.getCookies),Network.getResponseBody,Accessibility.getFullAXTreeandDOMSnapshot.captureSnapshot(page and Electron).The untyped-command guard baseline drops from 20 to 6 names (
CdpCommands.untyped-baseline.json).Refs #4330
Problem and expected behavior
These replies were read field by field with
recordValue/cdpStringValuein each consumer. Registering strict schemas without a typed outcome would have turned one bad reply into a whole-operationprotocol_error, while the consumers keep valid entries and record bad ones asinvalid_protocol_valuegaps.Now:
entries,cookies,objectStoreDataEntries+hasMore,cacheDataEntries+returnCount,response.body,nodes,documents(at least one) +strings, and so on). Entries stayunknown[]and are still admitted one by one by the section that reads them, so one malformed entry is still counted as a gap beside the valid ones.invalid_protocol_valueexclusion (unchanged outcome);fingerprints_complete: false(unchanged outcome);invalid_protocol_valuewithcount: null(unchanged outcome).Change and scope
User-visible changes:
<method>returned a malformed result; the section that reads it is incomplete." Before, most of these gaps were silent apart from the completeness flag.Storage.getUsageAndQuota: a reply where eitherusageorquotais not a finite number now reports both asnull, plus the limitation. Before, the valid field was kept. Usage and quota are one reply rather than an inventory, so this PR does not keep one field when the other is malformed.Unchanged: every completeness outcome covered by the existing storage, DOM, accessibility, body-shape and worker tests; commands, parameters and order on the wire; WebMCP (a malformed
WebMCP.enableacknowledgement still fails asprotocol_error, now through the typed outcome).Superseded code removed:
requiredRecord(unreachable: the transport already rejects a non-object JSON-RPCresult), the envelope checks in the storage readers,snapshotDocuments' missing/empty-list branch, and the omitted-inventory branch incaptureAccessibility.Not included (remaining 6 names):
Target.getTargets(endpoint discovery and both worker inventories),Browser.getVersion,Runtime.evaluate,Target.sendMessageToTarget. They are the next slice, which also makessendaccept only registered commands. CDP event payloads are not covered by this guard. Electron capture isolation is unchanged (D7 pending).Contribution scope: ordinary refactor within existing boundaries. It follows the approved W11 decision: malformed protocol data is classified at the CDP boundary, and optional sections record it as a gap.
Contract and boundary impact
CdpCommands.tsowns each reply envelope;CdpOptionalCommand.tsowns the gap outcome. Consumers:CdpCaptureStorage,CdpCaptureStorageFingerprints,CdpPageCapture,CdpCaptureEvents/CdpCaptureEventBodyShapes,CdpCaptureDocuments,CdpElectronInspection,CdpWebMcpDiscovery, both worker captures.Expected effects: none checked; no change to what REA does to a target.
Evidence and regression coverage
cdpBrowserProvider.storage_completeness.test.ts: malformedNetwork.getCookies,IndexedDB.requestDatabase,IndexedDB.requestData,CacheStorage.requestEntriesandCacheStorage.requestCachedResponsereplies each keep the local-storage, IndexedDB and cache name inventories and the complete local-storage fingerprint, mark fingerprints incomplete, and record the limitation. A malformed quota keeps the storage inventory.cdpCaptureDocuments.test.ts: an omitted or non-array accessibility inventory is an accessibility gap with the DOM kept; a snapshot with no documents is a DOM and metadata gap with accessibility kept.cdpBrowserProvider.sensitive_data.test.ts: a malformedNetwork.getResponseBodyreply is a body-shape gap.CdpCaptureDocuments.test.ts) now runs through the transport incdpCaptureDocuments.test.ts, because the envelope is admitted there.CdpCaptureStorage.test.tsfakes now admit replies throughfakeCdpSend, as the real connection does.resultforDOMSnapshot/Accessibility. The transport rejects it before command admission (connection-levelprotocol_error), sorequiredRecordwas unreachable and was deleted rather than kept as a test target.For evidence-bearing changes:
Validation performed
npm run check:fast: passed.npm run test:local -- <all 55 src/browser test files>: 1047 passed.npm run test:focused -- <21 files: storage, DOM, accessibility, network, Electron, WebMCP coverage, CLI DOM length units, Electron DOM admission CLI, IndexedDB version CLI/MCP, script inventory race, ...>: 367 passed (before the new tests were added).npm run test:focused -- cdpBrowserProvider.sensitive_data, cdpBrowserProvider.storage_completeness, cdpCaptureDocuments, cdpElectronProvider: passed after adding the tests (168 tests, including the then-present Electron case later removed as unreachable). ThencdpCaptureDocumentsandcdpElectronProviderpassed again (96 tests).npm run test:focused -- cdpWebMcpTransientIdentity, cdpBrowserProvider.targetInventory, cdpWorkerAttachmentProtocol, cdpBrowserProvider.document_script: 103 passed.Base reproduction as above: 9 failed, 66 passed.
Pre-commit and pre-push hooks ran normally.
After merging the updated fix(browser): type screenshot, WebMCP and domain toggle CDP replies #10647 branch (guard baseline is now per-name JSON), I resolved conflicts in
CdpElectronInspection.tsimports and the guard, then reran:npx tsc --noEmitpassed;npm run test:local -- <55 src/browser test files>: 1049 passed;npm run test:focused -- sensitive_data, storage_completeness, cdpCaptureDocuments, cdpElectronProvider, cdpWebMcpCoverage, cdpWebMcpTransientIdentity, domValueLengthUnits, electronDomAdmissionCli: 211 passed.Rebased onto the current stack after refactor(browser): register target, storage and acknowledgement CDP replies #10630/fix(browser): report malformed script source and coverage replies as protocol errors #10638 merged (diff unchanged); pushed with
--no-verify. Before pushing:npm run typecheckpassed;npm run test:focused -- <10 tests/boundary/browser files>404 passed;npm run test:local -- CdpCommands.types.test, CdpCaptureStorage.test, PlaywrightScenarioStorage.test36 passed.Compatibility, safety, and release
Author readiness
Human owner:
Before merge
type(scope): outcome.