You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BUG-55: a 500 answer is plain text with no CORS header, so the portal sees a network error #216
BacklogNot started: the work waits in the backlogbugSomething isn't workingclass:INVInnovation: a new feature, design, idea or methodsev:lowA small defect, a defect no code path reaches yet, or a cleanupstatus:openNo fix yet
What is wrong: An exception that no handler takes gives the answer 500 Internal Server Error as plain text. It is not an RFC 9457 problem, and it has no CORS header: Starlette's ServerErrorMiddleware sends it outside each middleware of the application, CORSMiddleware among them. So the portal, on another origin, sees a network error with no status, and a person cannot tell a failure of the service from a failure of the network. Other clients get a body that is not the one shape of each refusal (docs/02, "API contract").
Where: on 418e934: cmapi/src/cmapi/main.py has handlers for Problem, RequestValidationError, TierError and ValueError, and none for Exception. cmapi/src/cmapi/core/observability.py:89-92 counts the 500 and raises it again. The CORS middleware of #206 is added in create_app.
Not measured: the answer of a real browser. The cause is read from Starlette 0.41.3 (starlette/applications.py, build_middleware_stack: ServerErrorMiddleware is the outer one).
How to prove it: a test in cmapi/tests/service makes one route raise RuntimeError, calls it with a listed Origin, and reads the answer with raise_server_exceptions=False. It fails today: the body is not a problem, and Access-Control-Allow-Origin is absent. After the fix the answer is application/problem+json with a registered code, the CORS header and X-Request-Id, the detail has no text of the exception, and the log line has the traceback.
Research mandate: read Starlette's middleware order and FastAPI's guidance for a catch-all handler. Decide where the conversion goes (a middleware inside CORS, not an Exception handler, which runs outside it). The metric of 500 answers must still count each one.
Class
INV. The portal on the API needs a readable answer for each failure.
BacklogNot started: the work waits in the backlogbugSomething isn't workingclass:INVInnovation: a new feature, design, idea or methodsev:lowA small defect, a defect no code path reaches yet, or a cleanupstatus:openNo fix yet
Activity
CORS is off unless an origin is listed; the review's three findings (#…
Merge pull request #219 from ephico2real2/api-cors