refactor(protocol): use typed HTTP status codes - #457
Conversation
Signed-off-by: Bhuvan Agrawal <11240550+bhuvan002@users.noreply.github.com>
|
|
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 ignored due to path filters (1)
📒 Files selected for processing (9)
Included review availability: Your plan includes up to 12 reviews per rolling hour; 11 remain after this review. WalkthroughThe change replaces numeric upstream HTTP statuses with ChangesTyped HTTP status flow
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This refactor replaces raw HTTP status integers with typed status codes without any identified merge-blocking risk; it is merge-ready after normal checks and review. Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Comment |
* origin/main: (31 commits) feat(server): add Dockerfile for switchyard-server container image (NVIDIA-NeMo#421) fix: normalize empty content-filter responses instead of raising (NVIDIA-NeMo#358) feat(python): unify LLM classifier bindings (NVIDIA-NeMo#465) feat(libsy): record task_kind and agent_role on the run span (NVIDIA-NeMo#249) fix(translation): accept SSE data fields with no space after the colon (NVIDIA-NeMo#447) fix(client): strip api-key and OpenAI org/project headers before forwarding (NVIDIA-NeMo#420) fix(llm-client): detect native sglang context-overflow messages (NVIDIA-NeMo#426) refactor(protocol): use typed HTTP status codes (NVIDIA-NeMo#457) fix(translation): preserve chat reasoning details (NVIDIA-NeMo#415) docs(changelog): note packaging extras removal in Unreleased (NVIDIA-NeMo#433) docs(changelog): fix broken Metrics Reference link (NVIDIA-NeMo#432) feat(libsy-llm-client): Move retry logic from libsy to libsy-llm-client (NVIDIA-NeMo#431) fix(server): use normalized session IDs in routing stats (NVIDIA-NeMo#430) feat(benchmark): pre-bake hermes agent into dataset images for closed-book runs (NVIDIA-NeMo#350) fix: support json_object classifier responses (NVIDIA-NeMo#411) fix(metrics): extend LLM latency histogram buckets (NVIDIA-NeMo#385) feat(server): forward inbound Anthropic auth (NVIDIA-NeMo#372) fix(protocol): normalize nested metadata strings (NVIDIA-NeMo#422) Revert "ci: base full CI on changed paths (NVIDIA-NeMo#403)" (NVIDIA-NeMo#414) feat: Move `Decision::reasoning` to a log message (NVIDIA-NeMo#413) ... Co-authored-by: Michael Neale <michael.neale@gmail.com> Signed-off-by: Michael Neale <michael.neale@gmail.com> # Conflicts: # crates/switchyard-server/src/config.rs
What
This commit refactors the raw
u16status fields with more meaningfulhttp::StatusCodetypes. This allows us to get rid of magic numbers at a lot of places and also use the existing helper functions in thehttpcrate. This change also removes an unnecessary StatusCode -> u16 -> StatusCode round trip when propagating upstream HTTP errors to the server response.Why
Makes the code more readable and safe.
Closes #
How tested
cargo fmt --all --checkcargo check --workspace --all-targetscargo clippy --workspace --all-targets -- -D warningsswitchyard-protocol,switchyard-libsy,switchyard-llm-client, andswitchyard-serveruv run ruff check .cleanuv run mypy switchyardcleanuv run pytest tests/greenChecklist
Signed-off-by: Your Name <email>) per the DCO.Notes for reviewers
Anything reviewers should pay extra attention to — risky paths, follow-up tickets, intentional trade-offs.
Summary by CodeRabbit