Repository navigation
Closed
Labels
priority: mediumMedium prioritytype: featureNew feature or requestworkload: daysLikely takes days to resolve
Milestone
Description
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:
400problem details (RFC 9457) get the extension membererrorsin the form of RFC 9457's own example (section 3): one entry per invalid field, each withdetail: 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 parametersparameterwith 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 atypeURI for this problem type. - Nothing in the format is FOCA-specific: generic RFC 9457 clients understand
errorswithout 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,statusanddetailas 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).
Metadata
Metadata
Assignees
Labels
priority: mediumMedium prioritytype: featureNew feature or requestworkload: daysLikely takes days to resolve
Activity