Skip to content

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

Open

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.

Activity

  1. changed the title [-]Validator crashes on empty or non-mapping YAML roots[/-] [+]Validator crashes instead of reporting errors for invalid YAML structures[/+] on Jul 26, 2026
  2. ihadoop commented on Oct 10, 2026

    @ihadoop
    Contributor

    Re-tested on current main (642cb89): this looks resolved, so noting the evidence for triage.

    All four inputs the issue names now exit 1 through the reporter, with no traceback:

    empty.yaml      -> [Schema] (root): None is not of type 'object'              exit 1
    sequence root   -> [Schema] (root): [] is not of type 'object'                exit 1
    scalar root     -> [Schema] (root): 'just a scalar' is not of type 'object'   exit 1
    

    The issue's own reproduction command behaves as it asked it should:

    $ python validation/validate.py /dev/null --schema core-spec/ossie-schema.json
    Validation FAILED with 1 error(s):
      [Schema] (root): None is not of type 'object'
    

    (the schema file has since been renamed from osi-schema.json)

    Against the proposed scope:

    • Report the schema errors already collected for structurally invalid documents — done. The AttributeError escape routes were closed by fix(validation): report unreadable input or schema, not a traceback #534 (unreadable input or schema) and fix(validation): reject a schema file that is valid JSON but not a schema #542 (a schema file that is valid JSON but not a schema).
    • Run semantic checks only after schema validation has established their expected nested shapes — already the case: in main() the unique-name, reference, arity and SQL checks sit behind if not errors and isinstance(data, dict) and 'datasets' in data, and the ontology checks behind 'ontology' in data.
    • Focused regression coverage for empty, sequence, scalar and malformed nested inputs — validation/tests (181 tests) and validation/test_validate.py (53 tests) both pass on main.

    Not my call to close it — reporting only that the reproduction no longer fails, in case this is stale.

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