Skip to content

SchemaException error location formatting #1270

Description

@eggilbert

Greetings -
I'm using the 2.X version of the library, and I've noticed that the new exception in SchemaRegistry#validateSchemaNodeType (and probably #validateSchemaNodeNotNull too) from #1174 / #1250 backported in 2.0.2 don't appear to be honoring the SchemaRegistryConfig settings I have in place for error location formatting.

My SchemaRegistryConfig is created like this, and is configured to use PathType.JSON_PATH for error locations:

private static final SchemaRegistryConfig SCHEMA_REGISTRY_CONFIG = SchemaRegistryConfig.builder()
    .pathType(PathType.JSON_PATH)
    .errorMessageKeyword("message")
    .cacheRefs(false)
    .formatAssertionsEnabled(true)
    .failFast(false)
    .preloadSchema(false)
    .typeLoose(false)
    .build();

If I feed in an intentionally invalid schema and validate it against the specification or dialect schema to check syntax and structure, I receive an error location like $.properties.required in my test case. But when I try and construct the invalid schema itself through the SchemaRegistry, I trigger the new SchemaException with a message of Schema at #/properties/required must be object or boolean but was ARRAY where the location of the same field is reported as #/properties/required instead. It seems to be using the default of PathType.JSON_POINTER.

Is this the expected behavior?

This new exception is also just using the string message instead of the Error object like other SchemaException instances with an error location I was already catching and handling. That's not a big deal and I've fixed that assumption in my code to fall back to the message if needed, but I was expecting the errors to have consistent formatting when referring to invalid elements in the schema across the various operations and methods.

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