Repository navigation
fix(cdp): decode the base64 postData a continueRequest carries - #874
Conversation
|
Right fix — we shipped the same decode in our tree when wiring #569. Two contract notes from that implementation, since this PR routes through the shared One, the helper returns Two, the helper decodes leniently: |
|
Both notes were right, and the first one lands squarely on my own test name — it asserts "the request body must be the bytes the client encoded" while the decode still went through a Bytes, not Strict, and it does not wedge. The recovery property you named needed a reorder, and it is worth spelling out because the old shape was one line away from a wedge: Padding is optional in the decoder — encoders disagree about it and the group length is unambiguous without it — but a character outside the alphabet, padding with anything after it, and a final group of one symbol are all refused. One place I did not follow you, so it is not mistaken for an oversight: Verified in a Linux container on rustc 1.98: Each new claim was checked by breaking it. Putting the bytes back through
Taking the pause on the error path instead of leaving it fails only the two rejection tests, on |
`postData` is declared `binary` in the Fetch domain, so a client sends it base64-encoded -- the same wire type as `fulfillRequest`'s `body` four lines below, which is decoded. This arm passed the string through unchanged and `op_fetch_url` turns it into bytes with `String::into_bytes`, so the request body became the base64 text itself: a server reading a rewritten POST got neither the JSON nor the form the client meant to send. Decode it the same way. An absent `postData` still resolves to None, so a continue that does not rewrite the body leaves it alone rather than sending an empty one.
Two gaps the first pass left, both raised in review. The decoded postData still travelled as a String, so a rewritten POST that is a protobuf, a gzip stream or a multipart part had every non-UTF-8 sequence replaced with U+FFFD before reaching the wire. Continue's body is Option<Vec<u8>> now; op_fetch_url's override_body was already Vec<u8>, so the consumer loses a conversion rather than gaining one. The decoder also dropped every character outside the base64 alphabet and zero-padded partial groups, so raw text sent where base64 was expected became quietly mangled bytes -- the same silence this change set out to remove. decode_optional_binary refuses it instead, and both binary-carrying arms answer -32602 naming the field. Refusing needed the pause to outlive it: the resolution was built after intercepted_paused.remove(), so an error would have taken the pause with it and left the request unanswerable. It is built first now and the pause is taken only once it is Ok, so a corrected command on the same requestId still drives the fetch. fulfillRequest's body stays a String at the resolution boundary: it crosses op_fetch_url's JSON reply, where a Vec<u8> serialises as an array, so making that end-to-end is a wider change than this one.
ff831a8 to
3f9acc2
Compare
|
Rebased onto
What is kept from here is the strict decode, now layered on top rather than replacing it:
One thing I could not run: |
…errides fix(cdp): decode the base64 postData a continueRequest carries
What changed
Decode
Fetch.continueRequest.postDatafrom CDP base64 into raw bytes before sending the request. Keep those bytes throughInterceptResolution::Continue.bodyand the HTTP transport. Binary overrides previously reached the server as base64 text.Addresses the remaining continuation-body corruption in #716. Related to #569; this does not claim to resolve every navigation override issue.
Current head:
343e34e. Its source tree matches the locally validated tree8acba1ac667f3127180683b82e32a7ec4469b65c.Network.loadingFailedevents, header and method overrides, and URL-rewrite safety checks.Continue.bodyis nowOption<Vec<u8>>. Text callers usetext.into_bytes(); CDP clients need no configuration change.Validation
CARGO_INCREMENTAL=0 CARGO_BUILD_JOBS=4 cargo nextest run --release --features render -E 'test(continue_request_) + test(fulfill_request_) + test(fetch_resolution_) + test(intercept) + test(binary)' --no-fail-fast CARGO_INCREMENTAL=0 CARGO_BUILD_JOBS=4 cargo nextest run --release --features render --no-fail-fast CARGO_INCREMENTAL=0 CARGO_BUILD_JOBS=2 cargo build --release -p obscura-cli --bins --features render OBSCURA_BIN=/path/to/candidate python3 obstacle-course/run.py --json --runs 1 --warmup 02d08d9a8e860e423b47209434a9fba9c75e6eee6: 33/33.[0,128,255,16,195,40]instead of sending the textAID/EMMo. Normal fetch/XHR, inherited Request bodies, multipart files, fulfilled binary responses, omitted and empty overrides all pass. Same-session invalid-command rejection and retry now pass too.Rendering
Not applicable.
Performance
Intercepted body rewrites now decode base64 once and move a byte vector into the existing HTTP request. The normal request path is unchanged.
Five alternating current-main/candidate pairs after compilation and functional servers stopped, with identical successful workloads:
MCP median CPU is 60 ms for both revisions at 10 ms resolution. Changes are within the approximate 10% noise range; the smoke gate passes. No speedup claim or Chromium performance comparison. Comparing rewritten-body speed against main would be misleading because main sends the wrong data.
Remote paired performance CI also passes: both obstacle runs report 33/33, median per-stage latency ratio 1.00x, no stage above the reporting threshold. Five-pair smoke reports DOM latency +1.5%, RSS -0.2%; storage latency -3.3%, RSS unchanged. These changes remain inside the approximate 10% noise range.
Checklist