~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

pds xrpc writes an empty blob as nothing, {} only for an empty answer

Open
Open chadtmiller.com wants to merge into main from chadtmiller.com/monolith:fix/xrpc-empty-blob

pds xrpc printed {} for an empty blob served as JSON, so last night's nightly failed at seed 41. Now {} is only for an answer with neither a body nor a Content-Type. Also moves url to 2.5.9, past an advisory that fails every pull's cargo deny.

Claude Opus 5.5 · high

What changes

Spec. spec/COMMANDS.md, "Any call": {} for an answer with no body and no Content-Type, as a method that answers nothing; any other answer written as its bytes, so a blob of no bytes, under whatever Content-Type getBlob serves it, even application/json, writes nothing.

Harness. checkXrpc in harness/checks/commands.mjs: a host of the harness's own answers 200 with no body, with no Content-Type and with application/json, text/plain and application/octet-stream; pds xrpc must print {}\n for the first and nothing for the others. It runs in every --commands run, where the nightly's case needed a random draw.

CLI. crates/pds-cli/src/xrpc.rs: {} only when the answer is empty and has no Content-Type. A change file (patch).

Cargo.lock. url 2.5.8 to 2.5.9 (and form_urlencoded 1.2.3): RUSTSEC-2026-0592, a stack overflow in Url::origin() on nested blob: URLs, which cargo deny check now refuses, so every pull's gates fail at their first step until it lands.

Why

The nightly on main ff58fc8c88a3 failed at step 765 of seed 41 (--crash-every 15 --firehose --commands): command pds sync get-blob differs, the reference 0 bytes, the server's 3 bytes. The server served the empty blob as 0 bytes (its log: "bytes":0); the harness had routed the call through pds xrpc (harness/lib/xrpc.mjs draws one of tool, command and pds xrpc), which printed {}\n for an empty body under a JSON Content-Type, as the spec's "an answer with no body {}" allowed. A method that answers nothing is answered 200 with no Content-Type, so that alone tells the two apart.

How it was checked

The spec and harness commit pushed without the fix (with the url bump, so the gates reach the harness): the gates at fd9355563b69 fail in each of the three --commands runs (seeds 31, 32, 33) at step 0, pds xrpc query com.example.harness.empty type==application/json differs: spec/COMMANDS.md, "Any call", and nowhere else. With the fix, the gates, docs and citations at 4e1507f9d8b2 pass.

Shortcomings

A forwarded method whose service answers nothing under a JSON Content-Type now prints nothing rather than {}.

One gates run at fd9355563b69 failed on space_credentials::tests::credentials_are_verified_row_by_row (401 BadJwt for a credential whose iat is 5 seconds ahead, the skew's edge), which passed on the run again and on main: flaky, untouched here. Only a clock stepping back between the test's now and the check's seems to explain it.

Approved

This changes pds xrpc to print {} only for an answer with no body and no Content-Type. An empty body under any Content-Type is now written as nothing. That matches getBlob serving an empty blob under its own type, which was the nightly's failure.

I read the code change in xrpc.rs. json is None only when there is no Content-Type, so (None, _) if bytes.is_empty() does what the spec says. An empty body under JSON falls through to the bytes arm and writes nothing. The spec page "Any call" is updated and the changeset is written for those who call the server. The new harness check in checkXrpc is stricter and compares four cases against a host of the harness's own. The url bump to 2.5.9 only touches Cargo.lock, so it adds no crates. I found no change needed in docs/guide/calling.md, which doesn't describe this output.

The one cost is the one the body already names: a forwarded method whose service answers nothing under a JSON Content-Type now prints nothing instead of {}. The spec states that trade explicitly, so I'm not asking for a change.

Approved

1 approval

All checks have passed

3 passed, 1 skipped