Skip to content

feat: make error media type configurable #315

Closed

Description

@uniqueg

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?

  1. Add exceptions.media_type to ExceptionConfig, defaulting to application/problem+json (no change for existing apps), allowing e.g. application/json.
  2. Use it in _problem_handler_json and 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.
  3. Document when to change it (apps implementing a spec that declares application/json for 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) has Content-Type: application/json and 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

  1. added this to the v0.15.0 milestone on Oct 20, 2026
  2. added a commit that references this issue on Oct 20, 2026
    791b390
  3. uniqueg commented on Oct 20, 2026

    @uniqueg
    MemberAuthor

    Implemented in #317 (merged into dev, to be released with v0.15.0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions