Skip to content

Conversation

christopher-angel
Copy link
Collaborator

Description

When validating schema extensions the validator result isn't very helpful. Here is an example error:

validation failed: jsonschema: '' does not validate with https://stac-extensions.github.io/raster/v1.1.0/schema.json#/oneOf: oneOf failed

It would be useful to receive the report for the entire validation, especially the failed resource. With this change we should see the full validation result - example:

invalid collection: /path/to/failed/collection.json
[I#] [S#] doesn't validate with https://stac-extensions.github.io/raster/v1.1.0/schema.json#
  [I#] [S#/oneOf] oneOf failed
    [I#] [S#/oneOf/0/allOf/0] allOf failed
      [I#] [S#/oneOf/0/allOf/0]
        [I#] [S#/oneOf/0/allOf/0/required] missing properties: 'assets'
        [I#/type] [S#/oneOf/0/allOf/0/properties/type/const] value must be "Feature"
    [I#] [S#/oneOf/1/allOf/0] allOf failed
      [I#/item_assets/acd] [S#/oneOf/1/allOf/0/properties/item_assets/additionalProperties/$ref] doesn't validate with '/definitions/assetfields'
        [I#/item_assets/acd/raster:bands] [S#/definitions/assetfields/properties/raster:bands/$ref] doesn't validate with '/definitions/bands'
          [I#/item_assets/acd/raster:bands/0/nodata] [S#/definitions/bands/items/properties/nodata/oneOf] oneOf failed
            [I#/item_assets/acd/raster:bands/0/nodata] [S#/definitions/bands/items/properties/nodata/oneOf/0/type] expected number, but got string
            [I#/item_assets/acd/raster:bands/0/nodata] [S#/definitions/bands/items/properties/nodata/oneOf/1/enum] value must be one of "nan", "inf", "-inf"

This is accomplished by ensuring that the extension error is actually a jsonschema.ValidationError and then pass this to the newValidationError func to preserve context.

If for some reason we can't parse the error as expected, we go ahead and return it as usual.

Copy link
Member

@tschaub tschaub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@christopher-angel christopher-angel merged commit 43152aa into main Jul 15, 2024
@christopher-angel christopher-angel deleted the cangel/fix-validation-error branch July 15, 2024 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants