Skip to content

Bug: Extension schemas declaring draft-07 are validated as 2020-12 #159

Description

@nlebovits

Problem

stac-validator appears to validate extension schemas as JSON Schema 2020-12 regardless of the dialect declared by the schema.

This causes valid draft-07 extension schemas to crash validation.

For example, the Portolan extension declares:

"$schema": "http://json-schema.org/draft-07/schema#"

and uses the draft-07 tuple form of items:

"items": [
  {"$ref": "#/definitions/longitude"},
  {"$ref": "#/definitions/latitude"},
  {"$ref": "#/definitions/longitude"},
  {"$ref": "#/definitions/latitude"}
]

When stac-validator reaches this definition, it crashes with:

AttributeError: 'list' object has no attribute 'get'

The relevant code appears to hardcode 2020-12:

Resource(contents=schema, specification=DRAFT202012)
validator = Draft202012Validator(...)

Under 2020-12, items expects a schema rather than the draft-07 array form, which leads referencing to call .get("$id") on the array.

Expected behavior

The validator should respect the extension schema's declared $schema dialect.

The Portolan schema validates successfully with Draft7Validator, as do all 14 reference STAC objects tested against it.

Reproduction

Schema:

https://schemas.portolan-sdi.org/portolan/v0.1.1/schema.json

Any Portolan collection that exercises the bbox definition reproduces the crash. Catalogs do not, because they do not reach that definition.

The same objects validate successfully with the draft-07 validator and with Portolan's own validator.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions