Repository navigation
Description
Why?
FOCA sends all error responses as application/problem+json (hard-coded in foca/errors/exceptions.py, _problem_handler_json). Many GA4GH specifications declare application/json for their error responses instead, often with a problem-details-like schema: e.g., the Service Registry and service-info specs (status, title, detail). Apps implementing these specs therefore send a media type that the official spec does not list. Clients generated from, or responses validated against, the official spec may flag this.
Apps cannot fix this themselves: they can only declare application/problem+json in addition (FOCA merges specs, so declarations can be added but not removed), as elixir-cloud-aai/cloud-registry#96 did, or edit the vendored GA4GH specs.
How?
- Add
exceptions.media_typetoExceptionConfig, defaulting toapplication/problem+json(no change for existing apps), allowing e.g.application/json. - Use it in
_problem_handler_jsonand wherever else FOCA builds error responses, so that all error responses use it: errors raised by app code, Connexion's request validation and security errors, and 404/405 for unknown routes. - Document when to change it (apps implementing a spec that declares
application/jsonfor errors).
Content negotiation via the Accept header was considered and rejected for now: more logic and tests for little practical gain.
Acceptance criteria
- With the default, error responses are unchanged.
- With
media_type: application/json, every error response (app exceptions, request validation, security, unknown routes) hasContent-Type: application/jsonand the same body. - An invalid value fails config validation.
- Tests and documentation.
Follow-up: once released, elixir-cloud-aai/cloud-registry sets application/json and removes the application/problem+json declarations from additions.openapi.yaml, so that its error responses match the GA4GH spec exactly.
Activity
feat: make error media type configurable (#317)
uniqueg commentedon Oct 20, 2026
Implemented in #317 (merged into
dev, to be released with v0.15.0).