Repository navigation
fix(server): return ErrorResponse for framework-raised HTTP errors - #3117
Merged
Pangjiping merged 1 commit intoNov 26, 2026
Merged
Pangjiping merged 1 commit into
Pangjiping merged 1 commit into
Conversation
The error handler was registered for FastAPI's HTTPException, a subclass
of Starlette's. Errors the framework raises with the Starlette class (unknown
route 404, 405, unparseable body 400) bypassed it and returned
{"detail": ...} instead of the {code, message} ErrorResponse the spec
declares for every non-2xx response. Register the handler on the base class.
Signed-off-by: kongxin <kongxin326@gmail.com>
kongxinjun
requested review from
Generalwin,
Pangjiping,
hittyt,
jwx0925 and
ninan-nn
as code owners
November 26, 2026 01:34
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sandbox_http_exception_handleris registered forfastapi.exceptions.HTTPException, which subclasses Starlette'sHTTPException. Errors the framework raises with the Starlette class skip it and keep Starlette's default body:GET /v1/no-such-route{"detail":"Not Found"}{"code":"GENERAL::UNKNOWN_ERROR","message":"Not Found"}PUT /v1/sandboxes{"detail":"Method Not Allowed"}{"code":"GENERAL::UNKNOWN_ERROR","message":"Method Not Allowed"}PATCH /v1/sandboxes/{id}/networkpolicywith a non-UTF-8 body{"detail":"There was an error parsing the body"}{"code":"GENERAL::UNKNOWN_ERROR","message":"There was an error parsing the body"}The lifecycle spec declares
ErrorResponse(codeandmessagerequired, no other properties) for every non-2xx response, and the SDKs parse that shape. Registering the handler on Starlette's base class covers both. Status codes and headers (e.g.Allowon 405) are unchanged; FastAPI's ownHTTPExceptionis still handled the same way.Request-validation errors (422) are not touched.
Testing
Not run (explain why)
Unit tests
Integration tests
e2e / manual verification
tests/test_routes.py::TestFrameworkErrorResponses(unknown route, 405, unparseable body): 3 fail onmain, pass with the change.uv run pytest: 3197 passed, 34 skipped.uv run ruff check: clean.Found by running schemathesis against the lifecycle spec on a local Docker-runtime server.
Breaking Changes
Clients that read
detailfrom a 404/405 body now getcode/message, which is what the spec documents.Checklist