Repository navigation
fix(cli): cap the gateway's manifest pull at the manifest size - #2477
Merged
Merged
Conversation
The gateway read a bundle manifest under its normal --max-blob-mb (1 TiB by default) and checked the 64 MiB limit only on the bytes it had read. A /<hash>/ or /<hash>/<path> request for a large non-manifest blob paid for 64 MiB plus the lanes' read-ahead before it failed with a 502. The manifest pull now runs under manifest_cap_mb, the clamp that decdn get's entry fetch already applies, so its lanes request no byte past the cap. A blob over the cap, or one that does not parse as a manifest, is PullError::NotManifest and answers 404: nothing upstream failed. A malformed entry hash now names its entry. Closes #2474 Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
The focused changes preserve normal streaming and funding retries, with regression coverage and no identified blocking issues.
0 open findings
What changed in this PR
Bounds gateway manifest pulls to 64 MiB or the operator’s lower limit, reducing unnecessary paid downloads.
Changes:
- Shares the manifest cap between CLI fetches and gateway pulls.
- Returns 404 for oversized or invalid manifests while preserving funding retries.
- Adds regression tests and a changelog entry.
| File | Description |
|---|---|
| crates/cli/src/commands/gateway/tests.rs | Tests pull caps and manifest error responses. |
| crates/cli/src/commands/gateway.rs | Applies manifest limits and maps errors to 404. |
| crates/cli/src/commands/fetch/tests.rs | Tests shared cap calculation. |
| crates/cli/src/commands/fetch.rs | Extracts the shared manifest cap helper. |
| CHANGELOG.md | Documents bounded pulls and updated responses. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Review follow-up on #2474. The manifest 404 told the caller to fetch `/<hash>` for the raw blob even when the gateway's own --max-blob-mb is at or below the manifest cap, where that fetch hits the same cap and answers 502. The hint now names the real path, with its ?ns=, and only appears when the gateway's cap is higher. The read loop's backstop calls the bytes a blob, not a manifest. Tests: a cap stop that arrives after the first manifest bytes (the real client's timing), a valid bundle that serves its entry and index with the manifest pulled once, and the hint's gating. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 16, 2026
Closed
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 8 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. |
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.
What
The gateway reads a bundle manifest into memory for
/<hash>/and/<hash>/<path>. That pull ran under the gateway's normal--max-blob-mb(1 TiB by default), and the 64 MiB limit was checked only on bytes already read. So a request for a large non-manifest blob paid for 64 MiB plus the lanes' read-ahead before it failed with a 502. Anyone who could reach the gateway could spend the operator's funds this way.fetch.rs: the clampfetch_entry_hashalready applied is nowmanifest_cap_mb(0→ 64, otherwisemin(_, 64)), shared with the gateway.gateway.rs:start_pulltakes the cap.manifestpassesmanifest_cap_mb(self.common.max_blob_mb)andstreampasses the gateway's own cap, which is unchanged. The client driver ends withBlobTooLargebefore it opens a leg past the cap.PullError::NotManifestcovers aBlobTooLargefrom the manifest pull, the in-loop byte guard and aBundleManifest::parsefailure. It answers 404 (like the sibling "the bundle has no entry"), not 502, because nothing upstream failed.Fundingpasses through, so the capability-retry loop is unchanged.fetch::entry_hashdoes.?ns=) only when the gateway serves it: with--max-blob-mbat or below 64, the raw fetch hits the same cap, so no hint is given.Closes #2474
Reviewer notes
Gateway::manifestandover_manifest_capfirst.--max-blob-mbbelow 64, a real manifest over that cap also answers 404. The message names the effective cap.Verification
cargo fmt -- --checkcargo clippy -p decdn-cli --all-targets --all-features -- -D warnings(and the pre-commit clippy/doc hooks)cargo nextest run -p decdn-cli: 814 passedCARGO_BUILD_WARNINGS=deny cargo doc -p decdn-cli --no-deps --document-private-itemsmanifestfailsa_manifest_pull_is_capped_and_an_oversize_blob_is_not_found;NotManifestto 502 fails both 404 tests;finishedfailsa_cap_stop_after_the_first_bytes_is_not_found(the real client stops after the cap's worth has landed);--max-blob-mb 10check.a_bundle_serves_its_index_and_entries: a valid manifest serves its entry and index with 200, and the manifest is pulled once under the manifest cap.CHANGELOG.mdentry addedcontracts/changed: n/afix, lowercase subject🤖 Generated with Claude Code