apache / apache/ossie

Validator crashes instead of reporting errors for invalid YAML structures

Open
#270 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
2.1k
Forks
267
Avg merge
4d 20h
Merged PRs (30d)
24

Description

## 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`:

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

The command exits with an internal exception:

```text
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:

```text
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.

Contributor guide

Open the contributing guide

Research direction

Start in validation/validate.py and trace the existing schema validation reporter, then reproduce the failure with the provided uv command and malformed root inputs. Add focused regression coverage for empty, sequence, scalar, and malformed nested documents; done means the command exits 1 with collected schema errors and no internal traceback.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.