fix(server): preserve JSON rejection statuses - #406
Conversation
Signed-off-by: Ting-Hong Shieh <32212900+ting-hong-shieh@users.noreply.github.com>
Before / after HTTP snapshotI ran the same focused in-process Axum request matrix at the PR base ( OpenAI Chat endpoint:
Anthropic Messages endpoint:
The outer Anthropic envelope remains |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
WalkthroughThe server now preserves JSON extractor HTTP statuses, including ChangesRequest body error handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Mergeability Score: ⚪ Minimal · up to The change preserves API-specific JSON rejection statuses while retaining existing error envelopes, with no actionable merge-blocking risk remaining after normal checks and review. Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
What
JsonRejectionWhy
The shared JSON helper reduced every extractor rejection to a string, and
invalid_body_errorthen hard-coded HTTP 400. Clients therefore lost Axum's 415 and 413 distinctions, and Anthropic's existingrequest_too_largemapping was unreachable for oversized JSON bodies.Closes #400
Validation
cargo test -p switchyard-server --test server json_extractor_statuses_keep_api_specific_error_envelopes -- --nocapture— passedcargo test -p switchyard-server— passedcargo fmt --all --check— passedcargo clippy --workspace --all-targets -- -D warnings— passedcargo test --workspace— passed with loopback access enabled for the repository's local mock serversgit diff --check— passedNo live provider calls or secrets were used.
Summary by CodeRabbit