Skip to content

feat(axum): add safe diagnostics and trusted proxy metadata - #409

Open
ChristianPavilonis wants to merge 26 commits into
issue-393-buffered-body-limit-specfrom
issue-397-diagnostics-proxy-trust-spec
Open

ChristianPavilonis wants to merge 26 commits into
issue-393-buffered-body-limit-specfrom
issue-397-diagnostics-proxy-trust-spec

Conversation

@ChristianPavilonis

@ChristianPavilonis ChristianPavilonis commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Current review readiness — 2026-11-10

Ready for review at the publication head below. The required workspace and test aggregate have now passed in run42916832735; all 29 latest checks pass. Reviewers: aram356, prk-Jr, dhruv8sh.

Review transitions are independent of TS work and the combined integration audit; #462 remains draft. This current status supersedes historical draft-only prerequisites below without claiming unexecuted deployment/manual acceptance complete. All three reviewers are requested. Stack465 is the current grouping; #453 is excluded.

Current review-stack checkpoint

Publication head: 5bbff2bf6d6d853b470f76e7293b7ecfa55476f5. This cleanup preserves the existing feature unit and PR identity. The additional change is the completed generated-native build correction: image-only code now follows the scaffold's existing Fastly-example selection, with no request-policy change. Its focused generator/native proof is retained; fresh per-branch hosted checks are not assumed green.

Review order: #275 → #406 → #407 → #409 → #414 → #422 → #439 → #454. Draft integration checkpoint: #462. New SDK/group/codec/phase development and unrelated TS work are not prerequisites or additions to this PR. Earlier notes below retain their original tested revisions and limits; they are not a whole-tree pass for this new head.

Earlier implementation and proof notes

RC refresh checkpoint, 2026-11-10

Current head: 3b52b804e5570564cc95cdaaf4b9efc6307875ae.

Checked forwarding trusts the actual socket peer, validates the selected family and preserves original normalized-head accounting before stripping assertions and entering application callbacks. Diagnostics retain the existing terminal owner/time and redact raw values. Independent source review found no unresolved correctness defect.

The CLI-only diagnostics gate is fixed, with 57 CLI-only tests passing. Native ingress trust is now under edgezero_adapter_axum::trusted_proxy, leaving the current outbound legacy-API guard unchanged. Parent namespace proof passes 370 Axum unit, 28 contract and 32 production-hosting tests plus axum-only strict Clippy. Nested demo resolution matches existing exact workspace getrandom0.4.2/ipnet2.12.0 requirements; no manifest pin was relaxed.

This layer does not strip a future protected-CloudFront credential or prove a Geo reader identity.

Draft pending fresh hosted checks and the combined RC audit. Two unchanged native default-parallel deadline misses remain recorded and unclassified; serial passes and untouched-foundation parallel passes do not clear them. No timing bound was relaxed. No deployment, main merge, security-alert dismissal or review-thread resolution occurred. Historical design/review context follows.


Summary

  • Add opt-in, socket-peer-gated proxy trust and checked native ingress metadata. No proxies are trusted by default; managed admission strips both forwarding families.
  • Add safe correlated native records, request IDs, coherent work snapshots and an optional observer at the existing response terminal owner. Preserve application logging, completions, observers and custom rendering.
  • Use fixed native framework routing and JSON-deserialization error text, publish operator guidance, and add real proxy/TLS/socket regression coverage.

Changes

Crate / file Change
edgezero-adapter-axum Bounded literal policy/parser, owned metadata, strict settings, identity/counters/records, hosting integration and selected-status capture
edgezero-core Checked host witness, original normalized-head summary, timestamp-aware joined completion and bounded failure provenance; no report-shape or portable Tokio/Send change
Native fixtures Source-bound .2/.3 relays, verified test TLS with wrong-name control, 32 production-hosting cases, callback/panic/privacy/counter checks and defensive fallback tests
Docs Operator/migration guide, immutable reviewed specification and implementation/acceptance record

The approved JSON extension retains HTTP 400 and unmanaged serde detail. Custom renderers still own their response, but native framework JSON-deserialization errors now reach them as invalid JSON payload. Application-authored EdgeErrors are not globally sanitized. Managed raw-forwarding-header removal is documented as a compatibility change; the low-level converter remains a trust-policy bypass.

Dependency changes are four direct Axum edges to existing locked packages. Rustls and Tokio Rustls are dev-only. The published TLS private key is an explicitly public test asset, never a deployment credential.

Closes

Closes #397.

Stack and acceptance

Part of #391. This PR remains draft until the required integration and acceptance gates are satisfied.

Stacked above #407 using gh stack, at base 3308041b910b648af746c15e809ee86b96adc2e9. The user authorized implementation on this open stack. That exception does not satisfy accepted #275/#393 integration or authorize bypassing #394/#395 upload experiments. Accepted-stack, final-image and deployed-ingress acceptance remain deferred.

Test plan

Local checks passed for implementation commit 66a05e2:

  • cargo test --workspace --all-targets — 1,938 passed, one existing ignored generated-workspace compile smoke
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo fmt --all -- --check and git diff --check
  • cargo check --workspace --all-targets --features "fastly cloudflare spin"
  • All three adapter WASM checks: Fastly wasm32-wasip1, Cloudflare wasm32-unknown-unknown, Spin wasm32-wasip2
  • cargo test -p edgezero-adapter-axum --all-targets --all-features — 255 library, 13 contract and 32 hosting cases
  • cargo test -p edgezero-core — 731 library tests plus integrations/doctests; 13 existing ignored doc examples
  • Locked docs install, lint, format and build; compiled guide API/options/snapshot smoke
  • Excluded examples/app-demo workspace
  • Final image and deployed proxy/provider acceptance

docs/superpowers/plans/2026-10-06-axum-diagnostics-trusted-proxy.md records commands, timings, historical failures, source fingerprints, all 22 specification rows and proof boundaries. Final runtime-input manifest SHA256: ac40934b17bb6c521951f15090e2accf3059abcb4d386c6da74a69d95de8c9d7.

Local wire tests directly prove owned proxy peers, consumer agreement, verified TLS, selected 200 plus failure after an observed head/prefix, hook/cardinality preservation and graceful/grace-forced work release. Missing-peer, exhaustive parser/identity bounds, precise injected timing and defensive fallback branches remain service/unit evidence. Environment-derived secret/config error privacy is tested; declared-store/backend and actual outbound-origin experiments are not claimed. Explicit diagnostic stop fixtures do not prove the convenience second-signal-plus-native-snapshot combination. The existing supported convenience second-signal test is retained.

Independent source reviews found and resolved lost Abort failure classification and formatting drift. A maintenance-only duplicated IPv6 bracket split remains unchanged; node and authority port grammars differ. Docs installation reports seven existing audit vulnerabilities, two moderate and five high; no docs package changes were made.

Checklist

  • Follows CLAUDE.md; shared Cargo/global formatting centrally scheduled
  • No portable Tokio dependencies or Send migration
  • Brace-style route parameters and core HTTP types
  • No exporters, public diagnostics endpoints, tracing propagation or new terminal owner
  • Application hook/logger/renderer ownership preserved
  • Test keys are explicitly public fixtures; no deployment secrets committed
  • Distinguish local proof from downstream acceptance; keep the PR draft until its merge gates are satisfied

TS cutover follow-up, November 11

Native hosting invokes application head preparation after structural validation and before stripping forwarding fields. Protected Geo paths also capture facts before credential sanitation; invalid heads still skip application preparation.

Current head: 3708ffa418778b8ec3499daad132b1a3f9c7962f.

Local combined-RC qualification at 36f8e9c9c2c93661aaa73f2ca956cec3bc9e4c92: workspace tests 2,947 passed / 6 ignored; all-feature Axum 568 passed, including 36 production-hosting, 6 AWS startup and 4 celld startup cases; core doctests 19 passed / 13 ignored; strict workspace Clippy, formatting, feature compilation and Spin WASM check passed under Rust 1.98.1. Narrow TS consumer proof under Node 24.20.0: all four real proxy tests and typed prepared config/secrets/router startup passed. This is not final TS-stack/image/deployment qualification. Fresh hosted checks are still required.

Owned follow-up review checkpoint

  • Branch advanced through an ordinary merge; every previous public head remains an ancestor.
  • Current head: b8c65667e643f77dfa1cd61b79cee5bd7a95f552. Source tree a461a3dfd5ffa17698d452c034c935f59f365bea is byte-identical to previous head 31f46bde222ce3e942c1c801966ecc053a0305c9.
  • Related owned draft: #499. It is intentionally a placeholder until the author cleans feat: implement portable outbound HTTP and request lifecycle contracts #275 and the owned baseline/follow-up are reconciled.
  • Review base and ready/draft state are unchanged. The feature-only review diff is byte-identical to the pre-update diff.
  • Existing qualification remains tied to its recorded inputs. New hosted outcomes are reported separately; this history update does not qualify new source-version-bound binaries or move a release tag.

@ChristianPavilonis
ChristianPavilonis force-pushed the issue-397-diagnostics-proxy-trust-spec branch from 66a05e2 to 9fa1666 Compare November 10, 2026 19:54
# Conflicts:
#	crates/edgezero-core/src/app.rs
aram356 added a commit that referenced this pull request Nov 16, 2026
Brings #275 at b65e714 and the refreshed heads of #499, #460, #406,
#407, #409, #414, #422 and #439. Each PR merged the one below it, so
this merge has no conflicts. #409 resolved the one conflict on the way
up, in edgezero-core's app.rs imports, by keeping both.
aram356 added a commit that referenced this pull request Nov 17, 2026
Brings #275 at ea2549f and the refreshed heads of #499, #460, #406,
#407, #409, #414, #422 and #439, including #422's stock-celld store
service and its merge into #439. Each PR merged the one below it, with
no conflicts on the way up, so this merge has no conflicts.
@ChristianPavilonis
ChristianPavilonis removed this pull request from stack #501 November 17, 2026 17:14
Bring in main's Fastly SDK 0.13.3 upgrade (#529) with Viceroy 0.22.0
and the Fastly CLI 17.2.0 upgrade (#531), with PR #275's exact pins at
0.13.3 and url 2.5.9, its Viceroy readiness repair on 0.22.0 and its
typed Image Optimizer unavailability check for SDK 0.13.3.

examples/app-demo/Cargo.lock is merged by package entry. This PR's
getrandom 0.4.2 and wasip3 0.4.0 still need wasip2 1.0.4 and wit-bindgen
0.51.0/0.57.1, so those entries stay beside fastly-sys 0.13.3's wasip2
2.0.1 and wit-bindgen 0.62.0/0.63.0. The result equals a targeted
`cargo update -p fastly --precise 0.13.3` of this PR's lock.
Bring in PR #275's installation of the wasm32-unknown-unknown target
before the Viceroy 0.22.0 readiness repair builds, which the fastly
wasm tests and Portable record contracts (Fastly) jobs need.
@aram356

aram356 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

For the identity integration branch (#495), I pushed 2aea73c3 and 5a472184, two merges of #407's new heads.

Bring in PR #275's atomic conditional KV insert in the Viceroy readiness
repair, and the production hosting tests' held port reservations and
spawn-token respawn from PR #406 up, with each later PR's tests reading
the live host's address.
This carries PR #519's 09b09d9 and d86a5d3 (prk-Jr) changes to the
code this PR owns in production_hosting.rs: raw_request() and the
native failed-startup checks use the reservation/spawn lock and held
reservations.
These tests reused the address they reserved before spawning the host.
After a respawn on a fresh port that address belongs to whichever
listener took it, so requests through raw_request, LocalProxy and the
family checks now use server.addr().
@aram356

aram356 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

For the identity integration branch (#495), I pushed 1cd48710, 7d085b1f and 9c4a2f70.

Bring in PR #275's batch cutoff test fix, which advances the test clock
when the request arms its own deadline instead of after dispatch.
@aram356

aram356 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

For the identity integration branch (#495), I pushed c317517c, a merge of #407's new head that brings #275's 0e2a58ae, which fixes an intermittent failure of the batch cutoff test by advancing its clock when the request arms its deadline timer. It had no conflicts.

Keep failed trusted chains from substituting the socket peer for the client and use safe managed extractor errors without changing their status. Preserve typed stream failures, clock and cancellation semantics, and verify the native host and proxy fixtures.
@ChristianPavilonis

Copy link
Copy Markdown
Collaborator Author

Review follow-up: d37a57b8. The fixes were tested against the reviewed #407 base 9750b0e3.

  • The parallel port-race report is covered by the lower-stack reservation and respawn changes plus 7d085b1f and 9c4a2f70 in this PR. The 33-case hosting suite passed without serializing it. The separate connection.rs deadline flake is outside feat(axum): add safe diagnostics and trusted proxy metadata #409 and was left alone.
  • Added bare-development checks for invalid and non-Unicode native settings, plus wire coverage for both explicit builder paths. Core tests now assert both pre-dispatch fallback categories. The existing hosting test checks the original normalized-head byte formula. IPv6 parsing is covered in units; a separate IPv6 wire fixture is deferred.
  • A regressed egress instant no longer yields a native duration. Cancellation while validating a zero-length response stream records cancellation with no selected status. The response attempt still owns completion. When both native sinks are off, the guard releases accounting without allocating a request record.
  • The guide now explains why pre-service rejections are outside request telemetry. The changelog names the raw-header migration. The low-level converter remains a documented proxy-trust bypass.
  • The fixture key is public and test-only. Kept the existing TLS provider and verification; there is no scanner blocker in the reviewed checks. Provider changes, scanner exceptions, and certificate rotation tooling are deferred. The fixture README already records the expiry and renewal requirement.

Local Linux verification passed: 2,904 workspace tests, 33 hosting tests, 675 harness tests, strict Clippy, formatting, workspace feature compilation, Spin WASM, the Axum demo build, and docs format, lint, and build. macOS and deployed ingress were not run.

Stack dependency: #407 has since advanced to a3ad0428. A merge preview found conflicts in the native runner, options, service, and two hosting test files. This push carries only the reviewed #409 batch. It does not restack #409 or qualify that integration. The stack needs to be reconciled and retested before merge.

Keep the updated Axum startup and shutdown owner, explicit registries, and buffered JSON handling alongside proxy trust, request records, and diagnostics guard ownership. Preserve the production-hosting regressions from both parents.

@aram356 aram356 left a comment

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.

PR Review

Summary

Found while reviewing the rc/identity integration branch (#495) and traced to this PR. Each finding was re-checked at this head (3f6d0da6); line numbers refer to it.

One non-blocking portability finding.

Findings

Non-blocking

  • 🤔 ForwardedHost is checked only on managed Axum. See extractor.rs:247.

CI Status

  • GitHub checks at 3f6d0da6: 29 of 29 pass.

impl FromRequest for ForwardedHost {
#[inline]
async fn from_request(ctx: &RequestContext) -> Result<Self, EdgeError> {
if let Some(checked) = ctx.extensions().get::<CheckedEffectiveHost>() {

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.

🤔 ForwardedHost is checked only on managed Axum; elsewhere it still returns the raw client X-Forwarded-Host

Only the Axum adapter inserts CheckedEffectiveHost. On Fastly, Cloudflare and Spin this falls through to the legacy branch (:250-257) and returns whatever X-Forwarded-Host the client sent. A portable app that uses ForwardedHost for redirects, cache keys or tenant routing gets a trust-checked value on Axum and a client-controlled one on the other three. Document the split on the extractor and in each adapter guide, or have the other adapters insert CheckedEffectiveHost from their own trusted host source.

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.

Addressed in 381eb66 with docs. The extractor doc comment now says only the managed Axum host checks the value, through CheckedEffectiveHost. On Fastly, Cloudflare, Spin and the low-level Axum converter it reads X-Forwarded-Host, then Host, which the client controls, so it must not drive redirects, cache keys or tenant routing unless a proxy you control sets or strips the header. The Fastly, Cloudflare and Spin guides have the same note. docs/guide/handlers.md (around line 205) still recommends ForwardedHost behind a proxy without this caveat; I left that page alone.

@prk-Jr prk-Jr left a comment

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.

PR Review (follow-up)

Summary

Re-reviewed head 3f6d0da6 against stack base a3ad0428. The fix commit d37a57b8 addresses every item from my previous review, and I checked each one in the code rather than relying on the replies. One trust-boundary problem remains in the same area as the original trust-walk finding. Identity no longer collapses to the proxy, but a visitor who controls the leftmost part of the chain can still make EdgeZero discard the trusted proxy's host and scheme. One earlier doc question is also only half closed. I'm requesting changes for those two items.

😃 Praise

  • Failing closed on a malformed or unresolved trusted chain (effective_client() == None, Unavailable provenance, direct_peer() kept separately) is the right shape. The CHANGELOG entry makes the behavior change visible to upgraders.
  • The PendingValidation drop guard and the lazy record construction in RequestGuard::emit are small, focused fixes for the cancellation and allocation concerns.
  • The macOS proxy fixtures now skip with an actionable ifconfig lo0 alias message instead of failing with a misleading response head, and relay errors are no longer swallowed.

Prior findings status (my review at 31f46bde)

  • ✅ Trust walk collapses the client to the proxy's address (trusted_proxy.rs:413-438): Malformed and UnresolvedChain now clear effective_client and set client_source = Unavailable. Covered by direct_fallback / assert_client_unavailable and the service matrix at service.rs:3223-3240. A follow-on consequence for host/scheme is raised below as a new finding.
  • ✅ Duplicate Host becomes the checked direct host (trusted_proxy.rs:361-369): only a singleton Host (or a URI authority) yields a direct authority; duplicate_host_is_not_a_checked_direct_authority covers it.
  • ✅ Post-commit body-source failure category dropped (diagnostics.rs:563-565): NativeRequestRecord::source_failure is populated from the report and printed as source_failure=. The precommit zero-length path still retains the category through attempt.record_source_error (response.rs:672-675), and the wire test asserts the category.
  • ✅ Managed path/query/form/Validated* errors echo input (context.rs:808-814, 997-1001; extractor.rs): gated on FrameworkErrorDetail::CategoryOnly, which only the managed Axum service passes (service.rs:270-274). The dispatch tests cover both default and custom renderers in both modes.
  • 🔧 Unmanaged JSON redaction contradicts the guide: partially fixed. axum-diagnostics.md now says the low-level converter also uses fixed JSON text, and low_level_converter_keeps_native_fixed_json_parse_text pins it. docs/guide/adapters/axum.md:202-205 still says "Legacy/unmanaged JSON errors ... retain their existing behavior". See the inline comment.
  • ✅ Proxy/TLS hosting tests fail on macOS (production_hosting.rs:620-643, native_proxy.rs): the tests probe their source addresses and skip only on macOS AddrNotAvailable, panicking anywhere else. Relay errors now propagate through the worker JoinHandle<io::Result<()>>. I reran the axum suite locally on macOS without aliases; see CI Status.
  • ✅ (non-blocking) Guide omits the received-head preparer: the flowchart now has step P, and the text says the preparer sees unchecked headers (axum-diagnostics.md:89-104).

Findings

Blocking

  • 🔧 A visitor can still make EdgeZero discard the trusted proxy's host and scheme (trusted_proxy.rs:413, :708). See the inline comment.
  • 🔧 adapters/axum.md still contradicts the low-level converter's JSON redaction (docs/guide/adapters/axum.md:202-205). This is the remainder of the earlier ❓, and the fix is a one-paragraph doc change. See the inline comment.

Non-blocking

  • ⛏ Stale "falls back to the direct peer" sentence (axum-diagnostics.md:222-223). See the inline comment.
  • 🤔 Malformed forwarding is logged at WARN and the visitor can trigger it. Combined with the finding above, any client can produce one WARN record per request by sending a junk X-Forwarded-For. That is acceptable if WARN means "look at your proxy config", but consider INFO when the malformed slot lies beyond the trusted suffix, once the parser can tell the difference.
  • 📝 aram356's later 🤔 on ForwardedHost portability (extractor.rs:247) still applies. I'm not repeating it here.

CI Status

  • Hosted checks at 3f6d0da6: 29/29 pass (Run Tests, Run Format, CodeQL, Deploy actions).
  • Local, Rust 1.98.1 on macOS: cargo fmt --all -- --check PASS; cargo clippy -p edgezero-adapter-axum -p edgezero-core --all-targets --all-features -- -D warnings PASS; cargo test -p edgezero-core PASS (1,224 passed); cargo test -p edgezero-adapter-axum --all-targets --all-features PASS (435 lib, 28 contract, 40 hosting).
  • On macOS without loopback aliases, the four proxy/TLS hosting cases now print their skip notice instead of failing. They were not exercised here; Linux CI runs them.
  • Not rerun locally: the full workspace, feature check and WASM checks (hosted CI covers them).

),
None => return metadata,
};
let Ok(parsed) = parse_result else {

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.

🔧 A visitor can still make EdgeZero discard the trusted proxy's host and scheme

The identity collapse is fixed, but the whole-family check still covers the part of the chain the visitor wrote. Take the guide's own Cloudflare → LB topology. The visitor sends X-Forwarded-For: junk. Cloudflare and the LB append, and EdgeZero receives this from the trusted LB:

X-Forwarded-For: junk, 203.0.113.7, 198.51.100.10
X-Forwarded-Host: app.example.com
X-Forwarded-Proto: https

parse_node("junk") fails at line 708, the whole family becomes Malformed, and we return here with effective_scheme() == Http and effective_host() set to the direct Host. The LB-verified X-Forwarded-Proto: https and X-Forwarded-Host are thrown away. A 65th slot, an empty member, a 16 KiB prefix, or (for appending Forwarded proxies) an earlier element with proto=ftp does the same. whole_family_validation_includes_unselected_prefix_and_by_nodes and xff_empty_members_invalidate_even_good_host_and_proto currently pin this behavior.

Why it matters: the visitor chooses whether the trusted proxy's assertions apply. An app that builds absolute URLs from the checked scheme, or redirects when effective_scheme() != Https, will send that visitor an http:// link or a redirect back to the same HTTPS URL. The guide places a shared cache (Cloudflare) in front, and X-Forwarded-For is not part of the cache key. One request can therefore cache a redirect loop or http:// links for everyone (cache-poisoning DoS). It is also inconsistent: an unknown or obfuscated hop (UnresolvedChain) keeps the final-proxy host/scheme, but a junk hop further left drops them.

Fix (either one):

  • Preferred: validate only what the right-to-left walk consumes. Split the list into raw slots under the existing byte/slot bounds, then parse slots from the right and stop at the first untrusted or unknown node. A malformed slot to the left of that boundary is never interpreted. Host/proto (X-Forwarded-Host/-Proto singletons, or the final Forwarded element) are validated on their own.
  • Minimal: when the only defect is in the client-address chain, treat it like UnresolvedChain. The client is unavailable, the final-proxy host/scheme are kept, and Malformed is reserved for defects in the fields the final proxy owns.

Either way, please update the two tests above, the spec's "Malformed whole-set fallback" row, and the guide sentence "a present-empty value or empty member invalidates the complete selected family, including otherwise-valid host/proto". Then add a case asserting that a junk prefix behind a trusted suffix keeps https and the forwarded host.

Comment on lines +222 to +223
load balancer is trusted, it stops at the Cloudflare address. If every represented address is
trusted, it falls back to the direct peer as unresolved.

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.

⛏ This sentence describes the old behavior

After d37a57b8, a chain where every address is trusted gives UnresolvedChain with effective_client() == None and client_source() == Unavailable (trusted_proxy.rs:419-438). It no longer falls back to the direct peer. Read literally, this line tells operators that the LB address becomes the client, which is exactly what the fix removed.

Suggested change
load balancer is trusted, it stops at the Cloudflare address. If every represented address is
trusted, it falls back to the direct peer as unresolved.
load balancer is trusted, it stops at the Cloudflare address. If every represented address is
trusted, the chain is unresolved and the effective client is unavailable; `direct_peer()` still
reports the load balancer.

Comment on lines +202 to +205
Native-managed JSON deserialization failures return HTTP 400 with the fixed text
`invalid JSON payload`. Custom renderers receive that same fixed error, not serde detail.
Legacy/unmanaged JSON errors and application-authored `EdgeError` messages retain their
existing behavior. See [privacy limits](/guide/axum-diagnostics#timing-failures-and-privacy-limits).

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.

🔧 Still contradicts the low-level converter behavior (prior ❓ on unmanaged JSON detail, only partly resolved)

axum-diagnostics.md was corrected to say the low-level into_core_request converter attaches the native buffering policy and therefore also returns invalid JSON payload. low_level_converter_keeps_native_fixed_json_parse_text pins that. This paragraph still says unmanaged JSON errors keep their existing behavior, and that converter is the unmanaged path. Please align it:

Suggested change
Native-managed JSON deserialization failures return HTTP 400 with the fixed text
`invalid JSON payload`. Custom renderers receive that same fixed error, not serde detail.
Legacy/unmanaged JSON errors and application-authored `EdgeError` messages retain their
existing behavior. See [privacy limits](/guide/axum-diagnostics#timing-failures-and-privacy-limits).
Axum JSON deserialization failures on bodies carrying the native buffering policy return HTTP 400
with the fixed text `invalid JSON payload`. This includes the managed host and the low-level
`into_core_request` converter. Custom renderers receive that same fixed error, not serde detail.
Bodies without that policy, and application-authored `EdgeError` messages, retain their
existing behavior. See [privacy limits](/guide/axum-diagnostics#timing-failures-and-privacy-limits).

let direct_authority = if let Some(authority) = parts.uri.authority() {
parse_authority(authority.as_str().as_bytes()).ok()
} else {
let mut hosts = parts.headers.get_all(HOST).iter();

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.

😃 Nice, tight fix. The singleton-Host check now matches inbound_origin, URI authority still wins, and the test also covers a forwarded host being accepted while the direct authority is unavailable.


// Only this preparation step can suspend before selecting a response. If it is
// dropped, settle the begun attempt without claiming a status or starting a fallback.
struct PendingValidation<'attempt> {

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.

😃 Good call to settle the begun attempt as RequestCancelled when this future is dropped, instead of letting the Initial-state drop report ConversionError. cancelled_zero_length_validation_records_no_selected_status proves it end to end: there is no invented status, one record, and the source drops.

Fastly, Cloudflare, Spin and the low-level Axum converter supply no checked host, so the extractor returns the client's raw X-Forwarded-Host there.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Axum: add safe production diagnostics and trusted-proxy handling

4 participants