Skip to content

Validator crashes instead of reporting errors for invalid YAML structures #270

Description

@mattfaltyn

Summary

validation/validate.py can raise AttributeError after JSON Schema has already identified an invalid YAML shape. The exception prevents the existing validation reporter from showing the useful schema errors it collected.

This occurs when the document root is empty or not a mapping. It can also occur when semantic_model has an invalid nested shape because the semantic checks assume schema-valid mappings and lists.

Reproduction

From the repository root at 8c410f904c9bb20f683ef31292442e7bc432a8f6:

uv run validation/validate.py /dev/null --schema core-spec/osi-schema.json

The command exits with an internal exception:

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

Other affected inputs include a sequence root ([]), a scalar root, and a malformed nested value such as semantic_model: invalid.

Expected behavior

The command should exit 1 through the existing validation reporter:

Validation FAILED with 1 error(s):

  [Schema] (root): None is not of type 'object'

It should not emit an internal traceback.

Proposed scope

  • Report the schema errors already collected for structurally invalid documents.
  • Run semantic checks only after schema validation has established their expected nested shapes.
  • Add focused regression coverage for empty, sequence, scalar, and malformed nested inputs.
  • Keep the specification, public CLI, and dependency set unchanged.

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