Repository navigation
Closed
Labels
priority: highHigh prioritytype: maintenanceRelated to general repository maintenanceworkload: daysLikely takes days to resolve
Milestone
Description
Apps raise Werkzeug exceptions (werkzeug.exceptions.NotFound, ...) and key their exception maps by Werkzeug and Connexion 2 classes. In cloud-registry, proTES and trs-filer this happens in exceptions.py. FOCA's handler (foca/errors/exceptions.py) builds Flask Responses and reads Connexion 2's validation logger and problem classes (#461).
The ASGI release runs on Connexion 3 AsyncApp, without Flask:
- error handlers have the signature
(ConnexionRequest, Exception) -> ConnexionResponse; connexion.exceptions.ForbiddenandUnauthorizedare no longer Werkzeug classes;ExtraParameterProblembecomes a subclass ofBadRequestProblem.
A scratch test with Connexion 3.3.0 showed that a handler registered for Werkzeug's HTTPException catches subclasses and keeps their headers (e.g., Allow). So the change can be prepared now, and apps can stop importing Werkzeug and Connexion exceptions.
Do:
foca.errorsexception classes for the statuses apps use:BadRequest,Unauthorized,Forbidden,NotFound,MethodNotAllowed,Conflict,PayloadTooLarge,UnprocessableContent,InternalServerError,ServiceUnavailable, plus a base classHTTPError;- each with
code,descriptionand optionalheaders. - In 0.22 they subclass their Werkzeug counterparts, so existing handlers and
except werkzeug...keep working. In the ASGI release they get their own base class, with the same names and attributes.
- Stable names for Connexion's problems that apps map:
RequestValidationProblem(BadRequestProblem),ExtraParameterProblem,AuthenticationProblem(OAuthProblem),AccessDeniedProblem(Connexion'sForbidden). They are aliases of the Connexion 2 classes now and of the Connexion 3 classes in the ASGI release, so apps' exception maps don't change. - FOCA's own code raises
foca.errorsclasses:ownership*.py,access_control_server.py,service_info.py,connexion_app.py,auth.py(the RFC 6750 challenge goes inheaders). - Problem core without Flask:
build_problem(), header building and validation details (feat(errors): serve validation error details #461) work on plain data (exception, status, headers, problem dict). A thin Connexion 2 adapter turns the result into a Flask response. The ASGI release only adds an ASGI adapter. - Validation details no longer depend on the logger name
connexion.decorators.validationin the core. That logger name stays in the Connexion 2 adapter only.
Acceptance criteria
-
foca.errorsexports the classes and aliases above; documented (API reference,docs/configuration/exceptions.md), with an example exception map using onlyfoca.errorsnames. -
foca/raises no Werkzeug or Connexion exception directly; the problem core has noflaskimport. - Responses don't change: existing error tests pass unchanged, including headers (fix(errors): keep headers of HTTP exceptions #343) and validation details (feat(errors): serve validation error details #461).
- Tests show that a
foca.errorsclass and its Werkzeug base map to the same problem.
Decided
- Class names follow RFC 9110 (
PayloadTooLarge,UnprocessableContent, ...), as proposed. - Mapping raw Werkzeug exceptions keeps working in 0.22 but logs a deprecation warning (once per exception class); it stops at the first release candidate of the ASGI release. Document this in
docs/configuration/exceptions.mdand the migration guide. - Werkzeug stays installed (Connexion 3 depends on it); apps just must not import it.
Prepares #188.
Metadata
Metadata
Assignees
Labels
priority: highHigh prioritytype: maintenanceRelated to general repository maintenanceworkload: daysLikely takes days to resolve
Activity