Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

## Unreleased

### Axum buffered JSON limits and body API

Axum now defaults framework-managed JSON buffering to 2 MiB, exactly 2,097,152 bytes.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Breaking changes aren't flagged, and "representation unchanged" is inaccurate

For existing Axum apps, this entry changes behavior that the CHANGELOG normally marks with - **Breaking:** (see "Policy-Aware Axum Servers"):

  • The Axum Json<T> / ValidatedJson<T> default drops from 8 MiB to 2 MiB.

  • Explicit caps above the ceiling are now silently lowered to it and return 413:

    • always: json_within(N) and ValidatedJsonWithin<T, N>;
    • on application/json / +json requests: body_bytes(N), form_within(N), the Form family, and pre-dispatch body_bytes / transform_body(max_input, ..).

    "Explicit application caps may tighten the ceiling" hides that clamp.

  • New public method: Body::with_buffered_json_policy.

  • Body's Debug output gains an ingress_buffer field, and Body grows from 40 to 64 bytes, so "representation remain unchanged" doesn't hold.

Please also update the rustdoc that now describes the wrong behavior:

  • DEFAULT_INBOUND_JSON_BYTES ("accepted by JSON extractors (8 MiB)", context.rs:32)
  • body_bytes ("under the caller's byte cap", context.rs:343)
  • json_within ("Buffers at most max bytes", context.rs:654)

All three should mention the native ceiling.

Set `EDGEZERO__ADAPTER__JSON_BODY_LIMIT_BYTES` for standalone hosting, or use the fallible
`with_json_body_limit_bytes` builder on `AxumRunOptions` or `AxumDevServer`. Explicit
application caps may tighten the ceiling. Overflow is typed HTTP 413; malformed JSON remains
400. Taken streams, forwarding, manual collection, and other providers' defaults are unchanged.

The current `Body`/`BodyPayload` representation and exact egress ownership remain unchanged.
Ingress buffering policy and cache provenance survive context reconstruction independently of
mutable headers and extensions, and are removed at raw payload transport boundaries.

### Portable HTTP And Request Lifecycles (PR #275)

The changes below cover [PR #275](https://github.com/IABTechLab/edgezero/pull/275), including its
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ libc = "0.2"
miniz_oxide = { version = "=0.8.9", default-features = false, features = ["simd", "with-alloc"] }
log-fastly = "=0.13.1"
matchit = "0.9"
mime = "0.3"
once_cell = "1"
# 4.2 asserts that no read reference outlives its transaction. That check
# is what caught the `AccessGuard` bug in the axum KV store, so the
Expand Down
2 changes: 2 additions & 0 deletions crates/edgezero-adapter-axum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ axum = [
"dep:http-body",
"dep:hyper",
"dep:hyper-util",
"dep:mime",
"dep:reqwest",
"dep:redb",
]
Expand Down Expand Up @@ -51,6 +52,7 @@ http-body = { workspace = true, optional = true }
hyper = { workspace = true, optional = true }
hyper-util = { workspace = true, optional = true }
log = { workspace = true }
mime = { workspace = true, optional = true }
redb = { workspace = true, optional = true }
reqwest = { workspace = true, optional = true }
serde = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions crates/edgezero-adapter-axum/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,7 @@ mod tests {

#[tokio::test(flavor = "current_thread")]
async fn json_extractor_overflow_reaches_custom_renderer_without_retry_after() {
use edgezero_core::context::DEFAULT_INBOUND_JSON_BYTES;
use crate::run_options::JsonBodyLimit;
use edgezero_core::extractor::Json;

#[edgezero_core::action]
Expand All @@ -1517,7 +1517,7 @@ mod tests {
.body(Body::from("extractor overflow"))
.expect("custom error response")
});
let cap = DEFAULT_INBOUND_JSON_BYTES;
let cap = JsonBodyLimit::DEFAULT.get().get();
let body = serde_json::to_string(&serde_json::json!("x".repeat(cap - 1)))
.expect("valid oversized JSON string");
assert_eq!(body.len(), cap + 1);
Expand Down
Loading
Loading