Skip to content

feat: report invalid fields in 400 responses #586

Closed

Description

@uniqueg

Problem

When a request body is invalid, FOCA apps answer 400 with problem details whose detail is a free-text message, and request validation stops at the first error. Clients can show that text only as a general error: they can't tell which field is wrong or why, and users fix one field per submission. To show errors at the right fields, clients would have to copy the app's validation rules, which then drift from the server's (see the discussion in elixir-cloud-aai/cloud-components#510, where @anuragxxd proposed this approach).

Proposal

Let every FOCA app report all invalid fields of a request in a machine-readable way, so that clients need no validation rules of their own:

  • 400 problem details (RFC 9457) get the extension member errors in the form of RFC 9457's own example (section 3): one entry per invalid field, each with
    • detail: a readable message;
    • pointer: JSON Pointer (RFC 6901) to the field in the request body, as a URI fragment like in the RFC's example, e.g. #/organization/url; for query, path and header parameters parameter with the parameter's name instead;
    • code: a stable, kebab-case code, e.g. required, too-long, invalid-format, scheme-not-allowed (our extension of the entries, which RFC 9457 allows).
  • A stable top-level code (e.g. invalid-request) and a type URI for this problem type.
  • Nothing in the format is FOCA-specific: generic RFC 9457 clients understand errors without knowing FOCA, and FOCA's clients don't depend on FOCA's codes to show the messages.
  • Collect all errors of a request, not only the first: schema validation of the request (OpenAPI/JSON Schema) and the app's own checks (e.g. check_url()), which apps raise through a FOCA exception that carries field errors.
  • Document the format and the generic codes in FOCA's docs and in a reusable OpenAPI schema that apps reference in their specifications; apps document their own codes there too.
  • Keep title, status and detail as they are, so that existing clients keep working.
  • Design it with the move to Connexion 3 (1.0.0-rc1) in mind, where request validation and error handlers change.

Follow-ups

  • Apps adopt it (first: Cloud Registry for service registrations).
  • Cloud Components show the errors at the fields (design package first, then the app components).

Activity

  1. added
    priority: medium
    status: triage
    type: feature
    workload: days
    on Nov 1, 2026
  2. added
    status: in progress
    and removed
    status: triage
    on Nov 5, 2026
  3. added this to the v0.22.0 milestone on Nov 5, 2026
  4. removed
    status: in progress
    on Nov 9, 2026
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

    priority: mediumtype: featureworkload: days

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions