Repository navigation
feat(cli): decdn get streams one bundle entry to stdout with -o - - #2467
Conversation
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 5 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
There was a problem hiding this comment.
🔵 Needs a closer look
The change alters the shared keystore-unlock and paid-fetch flow (new multi-fetch payment path plus the Payer OnceCell refactor affecting all blob fetches), which is financially sensitive and warrants human confirmation despite no concrete defects found.
0 open findings
What changed in this PR
This PR extends decdn get so that an entry URI (decdn:<hash>/<path>) can be streamed to stdout with -o -, matching the behavior already available for raw blob URIs (e.g. decdn get 'decdn:<hash>/<path>' -o - | mpv -). Because an entry URI names exactly one file, routing it through the single-blob fetch path is a natural fit. Previously this combination errored with "-o - (stdout) takes a blob URI".
The entry-to-stdout run reads the bundle manifest into memory (capped at the shared MAX_MANIFEST_BYTES, 64 MiB), looks up the entry's blob hash, and streams that blob to stdout — both fetches share one FetchHost and one Payer/pool. The keystore Payer now caches its loaded signer in a OnceCell, so the two fetches prompt for the password once.
Changes:
- Route an entry URI with
-o -tofetch::fetch, which reads the manifest then streams the entry blob to stdout (newfetch_target/entry_hash/ManifestBuf). - Make the keystore
Payerload and reuse its signer via atokio::sync::OnceCellso multiple fetches unlock once; shareMAX_MANIFEST_BYTESfromfetch.rs(removed fromgateway.rs). - Update flag validation (
-o -now valid for an entry URI; bundle-only flags rejected on entry-to-stdout) plus help/doc text and unit + e2e tests.
| File | Description |
|---|---|
crates/cli/src/commands/fetch.rs |
Adds fetch_target/entry_hash/ManifestBuf, refactors fetch to route via uri, and makes the keystore Payer load its signer once through a OnceCell; defines shared MAX_MANIFEST_BYTES. |
crates/cli/src/commands/get.rs |
Routes an entry URI with -o - to the blob fetch (streams_one_blob/is_stdout) and relaxes/updates -o - flag validation. |
crates/cli/src/commands/gateway.rs |
Imports MAX_MANIFEST_BYTES from fetch.rs instead of defining its own copy. |
crates/common/src/cli/get.rs |
Documents the new -o - form for an entry URI in help text. |
crates/cli/src/commands/get/tests.rs |
Adds unit tests for entry-to-stdout routing and the bundle-flag rejection rule. |
crates/e2e/tests/cli_fetch_stdout.rs |
Parametrizes the stdout e2e test over blob vs. entry targets and seeds a manifest blob. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
`decdn get decdn:<hash>/<path> -o -` reads the bundle manifest into memory and streams that entry's blob to stdout, on one fetch host and one payer. The keystore payer unlocks once across both fetches. A whole bundle (`decdn:<hash>/`) still needs an output directory, and the bundle-only flags are an error on an entry URI to stdout. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`decdn get decdn:<h>/<path> -o -` reads the manifest, then streams the entry. Review fixes to that route: - The manifest fetch clamps --max-blob-mb to the 64 MiB manifest cap, so the lanes request and pay for no more than a manifest can be. A larger blob fails with a hint to drop the path. - An entry-fetch error names the entry and its blob hash. Without it, a missing entry blob reads "check the hash" about the manifest hash the user typed. - The manifest fetch logs its own `fetch timings` event (output="manifest"), so the command's time to first byte is the entry's first byte on stdout. - bundle_pull refuses `-o -`, so a misroute cannot make a directory `-`. - Unit tests for the entry lookup and the ManifestBuf cap. The e2e lists a decoy entry first, asserts the watermark covers both fetches, and counts password reads through an unused password file (a per-fetch unlock fails it). - CHANGELOG, README `get` table, and adr/appendix-bundles.md § Pull name the route. Stale one-fetch comments are fixed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
02ddd48 to
4e09454
Compare
Summary
decdn get 'decdn:<hash>/<path>' -o - | mpv -failed with "-o -(stdout) takes a blob URI". An entry URI names exactly one file, so it streams to stdout like a blob now.-o -runs the blob fetch. The fetch reads the bundle manifest into memory, finds the entry, and streams its blob to stdout. Both fetches run on oneFetchHostand onePayer, so they share one pool. This is the route the gateway already takes for an entry. An entry URI without-ostill goes to the bundle pull and lands at./<name>(feat(cli): make decdn get -o optional with per-target defaults #2466).--max-blob-mbtoMAX_MANIFEST_BYTES(64 MiB, the constant the gateway uses, now shared fromfetch.rs). So the lanes request and pay for no more than a manifest can be. A larger blob fails with a hint to drop the path.Payerkeeps the loaded signer in aOnceCell, so the manifest fetch and the entry fetch prompt for the password once.-o -on a whole bundle (decdn:<hash>/) is still an error. Bundle-only flags (--jobs,--overwrite,--json, ...) are an error on an entry URI to stdout, since that run is one blob.bundle_pullitself refuses-o -, so a misroute fails rather than making a directory-.GetArgshelp, CHANGELOG, the READMEgettable, andadr/appendix-bundles.md§ Pull name the new-o -form.Commits
feat(cli): decdn get streams one bundle entry to stdout with -o -: the feature, rebased onto feat(cli): make decdn get -o optional with per-target defaults #2466 (-ois optional;fetchtakes the resolvedDestinationpath).fix(cli): bound and label the entry-to-stdout manifest fetch: review fixes. They add the manifest cap clamp, entry-error context, a separate manifest timings event, thebundle_pullguard, tests and docs.Reviewer notes
fetch timingsevent withoutput="manifest". The command's own event reports the entry's first byte on stdout.-o -stream. A re-run picks up the new pool.max_blob_mbyet, so an oversized "manifest" there still pays up to the cap before it fails. That is out of scope here.Test plan
cargo nextest run -p decdn-cli -p decdn-common(1283 passed). It covers:-oentry_hash: picks the named entry, missing entry, not a manifest, malformed hashManifestBuf64 MiB boundarycargo nextest run -p decdn-e2e --features anvil-e2e -E 'binary(cli_fetch_stdout)': both tests pass. For the entry test:--keystore-password-filewarningOnceCellremoved, it fails with "read the keystore password 2 times".cargo clippy --workspace --all-targets --all-features -D warnings,cargo fmt --check,cargo docwith warnings denied, pre-commit hooks🤖 Generated with Claude Code