Skip to content

fix: don't echo request values in validation errors #732

Closed

Description

@uniqueg

When Connexion's request validation rejects a request, FOCA puts the validator's message as detail in the 400 response. This happens with exceptions.validation_details, which is the default. The message comes from jsonschema, via Connexion 2, and quotes the rejected value. For parameters, it also includes the schema. For example, on dev:

  • Body {"age": "abc"} against type: integer: "detail": "'abc' is not of type 'integer' - 'age'".
  • Query ?mode=abc against enum: [a, b]: "detail": "'abc' is not one of ['a', 'b']\n\nFailed validating 'enum' in schema:\n {'type': 'string', 'enum': ['a', 'b']}\n\nOn instance:\n 'abc'".
  • Body with an unexpected key: "detail": "Additional properties are not allowed ('abc' was unexpected)".

The errors member that FOCA adds says the same without quoting values, e.g., {"detail": "Must be of type integer.", "pointer": "#/age", "code": "invalid-type"}.

Quoting request values back to the caller is unnecessary. It can reflect content into responses and logs of intermediaries, and it shows schema internals. FOCA's own logs already avoid the values (they log the field locations and codes). The only alternative today, validation_details: false, drops detail and errors altogether.

The message is passed through by FOCA (foca/api/validation.py, foca/errors/exceptions.py), so FOCA can fix it without changing Connexion.

Do:

  • Add an option to exceptions that replaces the validator's message in detail with one built from the invalid fields, without values. For example: Invalid fields: #/age (invalid-type). The errors member stays as it is.
  • Keep the current behaviour as the default, because apps' tests assert the validator's messages (proTES, cloud-registry). Recommend the option in the docs.
  • Tests: body, parameter and unknown-parameter rejections, with the option on and off.
  • Docs: the configuration reference for exceptions, and the migration guide to 0.22.

Acceptance criteria

  • With the option set, no 400 response from request validation quotes a value of the request in detail.
  • Without it, responses are unchanged.
  • The option is documented, including when to use it.

Activity

  1. added this to the v0.22.0 milestone on Nov 7, 2026
  2. added
    priority: medium
    status: in progress
    type: bug
    workload: hours
    on Nov 7, 2026
  3. added a commit that references this issue on Nov 7, 2026
  4. removed
    status: in progress
    on Nov 7, 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: bugworkload: hours

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions