fix(blaze): bound HTTP request bodies - #2293
Conversation
|
@codex review This PR bounds ordinary Blaze HTTP request bodies with a configurable default while preserving the existing guest-operation envelope. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a59f4fbd83
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
a59f4fb to
9c43a28
Compare
|
@codex review Please re-review the current head |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
9c43a28 to
7c2e2e1
Compare
|
@codex review This PR bounds daemon HTTP request bodies before dispatch while preserving the existing guest-operation envelope. Please review the complete pull request: every commit, the cumulative diff against the base branch, and the implementation, tests, and documentation as one submitted change. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7c2e2e1e11
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
cd52edf to
7036cac
Compare
|
@codex review This PR bounds daemon HTTP request bodies before dispatch while keeping request-body error codes distinct from other payload limits. Please review the complete pull request: every commit, the cumulative diff against the base branch, and the implementation, tests, and documentation as one submitted change. |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review This PR enforces a configurable body-size limit for ordinary Blaze HTTP routes while preserving the existing guest-operation envelope and distinct error codes. |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This enables daemon routes without a dedicated protocol envelope, including template import, to reject oversized request bodies before dispatch. Use a validated api.max_body_bytes default for ordinary routes and a shared limit-aware collector that checks both Content-Length and streamed bytes. Malformed length or body reads return 400; size violations return 413. Guest exec, read, and write keep their existing 22 MiB envelope and stable error code. The limit is per request and does not bound aggregate concurrent memory. Fixes: 4ec67cf ("feat(blaze): implement sandbox guest operations (alibaba#2217)") Signed-off-by: Weisson <Weisson@linux.alibaba.com>
7036cac to
9daea49
Compare
|
@codex review This PR enforces a configurable body-size limit for ordinary Blaze HTTP routes while preserving the existing guest-operation envelope and distinct error codes. |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Why
Guest exec, read, and write already use a bounded HTTP envelope, but daemon
routes without a dedicated envelope could still buffer the complete request
body before dispatch. That now includes template import, which accepts
operator-supplied JSON large enough to make the missing ordinary-route boundary
an immediate release concern.
The daemon needs one predictable per-request limit for ordinary routes without
reducing the larger envelope required for guest file transfer.
What changed
Before:
envelope.
sending.
After:
api.max_body_bytessetting, which defaults to 1 MiB.Content-Lengthbefore pollingthe body and also stops when streamed bytes first cross the selected limit.
HTTP 400; ordinary size violations return HTTP 413 with
request_too_large.request_too_largecode is reserved for HTTP collection limits. Otherpayload-capacity failures may also return HTTP 413, but do not use this code.
guest_request_too_largeresponse.configured boundary before dispatch.
the same route-specific behavior.
The request flow becomes:
Commit
9daea49ed7a8— bound daemon HTTP request bodies. Adds theconfiguration contract, shared collector, 400/413 mapping, route-specific
limit selection, focused tests, example, and bilingual documentation.
These changes belong in one PR because they implement one daemon-entry
boundary. The configuration selects the limit, the collector enforces it, the
API maps its result, and the tests and documentation define the same observable
contract. Splitting any of those pieces would leave either an unenforced
setting, an undocumented behavior change, or a collector without stable API
semantics.
Still to do
cut; the
fixeslinkage then closes blaze: bound HTTP request body collection #2292.Related issue
fixes #2292
User and operator impact
Existing configurations remain valid and receive the 1 MiB ordinary-route
default. An ordinary request above that limit now receives HTTP 413 instead of
being fully buffered. Operators whose ordinary requests intentionally exceed
1 MiB can set a larger positive
api.max_body_bytesvalue before deployment.Guest command and file routes remain capped at 22 MiB independently of this
setting, so their existing 16 MiB decoded-file limit and error code do not
change. The new boundary applies per request; it does not cap aggregate memory
across concurrent requests.
Risk and compatibility
The configuration field is optional and defaults through serde, so existing
files continue to parse. The compatibility change is intentional: ordinary
bodies above 1 MiB are rejected by default. Set
api.max_body_bytesto asuitable positive byte count before deployment when an existing caller needs a
larger ordinary payload. A zero value is rejected during configuration
validation.
Validation
Exact public commit:
9daea49ed7a8adc35a62b8b7db2d44079d61b230Tree:
245ae6ae29f41d6a53969b3c5a9aab97aa07d391Parent:
ba20d94d19a73e5b781cab0c687d4034ad0d0daeGitHub's merge ref is
018e793fc7075e56c2a55aa0d41f159a2bf7afea. Its ordered parents are thecurrent
maincommit and the exact public head, and it has the same tree asthe public head.
The public commit was downloaded from GitHub by exact SHA. The archive SHA-256
is:
931b010307e2160095aed9c962edb70cff5e3a47e44b97eb8659ee3b05de5611The archive records the exact public commit, and an independent Git-object
reconstruction produced the expected tree. Native Linux x86_64 validation used
Rust and Cargo 1.88.0 with locked, offline dependencies and a separate fresh
target directory for each stage:
cargo fmt --all -- --check;denied;
(
blaze-core54 andblazed260) and 332 passed with all features(
blaze-core54 andblazed278), with 0 failures;denied;
tests.
Repository documentation naming and bilingual parity checks, relative-link
checks, commit-message and trailer checks, and the parent-to-head
git diff --checkpassed against the same tree and commit message. The sourcetree was reconstructed again after validation and remained unchanged.
Hosted Components, Docs, Pages, and PR Lint passed for this exact head.
Review status is reported separately by GitHub.
Documentation and rollback
The example configuration, component README in English and Chinese, and Blaze
user guide in English and Chinese document the default, override, response
status, and guest-route exception. CHANGELOG aggregation remains reserved for a
release version update.
To retain larger ordinary requests, set
api.max_body_bytesto a suitablepositive byte count. Revert this commit to restore the previous ordinary-route
collection behavior.