Skip to content

Improve error messages when json schema validation fails #615

Open
@aaronsteers

Description

@aaronsteers

We get really noising and difficult to parse error messages when manifests don't successfully validate against the json schema.

JSON Schema (and Pydantic) have a feature called "discriminator" which can help with this:

https://docs.pydantic.dev/latest/concepts/unions/#discriminated-unions

When Union validation fails, error messages can be quite verbose, as they will produce validation errors for each case in the union. This is especially noticeable when dealing with recursive models, where reasons may be generated at each level of recursion. Discriminated unions help to simplify error messages in this case, as validation errors are only produced for the case with a matching discriminator value.

Today: we get a huge error of the input not matching one of n "anyOf" conditions, which could be tens or hundreds of lines of error, without explicitly naming the field that was extra or missing.

Afterwards: we would get an error like field 'foo' is missing or unexpected field 'food' field

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions