openapi-spec-validator icon indicating copy to clipboard operation
openapi-spec-validator copied to clipboard

Nondescript error message/internal exception on ill-formed property spec

Open chenz-svsarrazin opened this issue 1 month ago • 0 comments

With this ill-formed spec:

openapi: 3.1.0
info:
  version: "1"
  title: "Title"
components:
  schemas:
    Component:
      type: object
      properties:
        name: string # error here

... the output is empty/nondescript:

$ openapi-spec-validator wrong.yaml 
wrong.yaml: Error: 

This is the internal exception thrown:

Traceback (most recent call last):
  File "/path/to/openapi-spec-validator/.venv/bin/openapi-spec-validator", line 7, in <module>
    sys.exit(main())
  File "/path/to/openapi-spec-validator/openapi_spec_validator/__main__.py", line 106, in main
    validate(spec, base_uri=base_uri, cls=validator_cls)
  File "/path/to/openapi-spec-validator/openapi_spec_validator/shortcuts.py", line 48, in validate
    return v.validate()
  File "/path/to/openapi-spec-validator/openapi_spec_validator/validation/validators.py", line 70, in validate
    for err in self.iter_errors():
  File "/path/to/openapi-spec-validator/openapi_spec_validator/validation/caches.py", line 62, in __next__
    item = next(self.parent)
  File "/path/to/openapi-spec-validator/openapi_spec_validator/validation/caches.py", line 31, in __next__
    item = next(self.iter)
  File "/path/to/openapi-spec-validator/openapi_spec_validator/validation/decorators.py", line 27, in wrapper
    for err in errors:
  File "/path/to/openapi-spec-validator/openapi_spec_validator/validation/validators.py", line 91, in iter_errors
    yield from self.root_validator(self.schema_path)
  File "/path/to/openapi-spec-validator/openapi_spec_validator/validation/keywords.py", line 453, in __call__
    yield from self.components_validator(components)
  File "/path/to/openapi-spec-validator/openapi_spec_validator/validation/keywords.py", line 435, in __call__
    yield from self.schemas_validator(schemas)
  File "/path/to/openapi-spec-validator/openapi_spec_validator/validation/keywords.py", line 190, in __call__
    yield from self.schema_validator(schema)
  File "/path/to/openapi-spec-validator/openapi_spec_validator/validation/keywords.py", line 155, in __call__
    yield from self(
  File "/path/to/openapi-spec-validator/openapi_spec_validator/validation/keywords.py", line 113, in __call__
    if "allOf" in schema:
  File "/path/to/openapi-spec-validator/.venv/lib/python3.9/site-packages/pathable/paths.py", line 173, in __contains__
    return key in self.accessor.keys(self.parts)
  File "/path/to/openapi-spec-validator/.venv/lib/python3.9/site-packages/jsonschema_path/accessors.py", line 73, in keys
    raise AttributeError

Revision tested is 118ad6125b35df075ed78d61f4f90d6a0abc1c88 Python 3.9.5

attrs==25.4.0
jsonschema==4.24.1
jsonschema-path==0.4.0b1
jsonschema-specifications==2025.9.1
lazy-object-proxy==1.12.0
openapi-schema-validator==0.6.3
-e git+https://github.com/python-openapi/openapi-spec-validator.git@118ad6125b35df075ed78d61f4f90d6a0abc1c88#egg=openapi_spec_validator
pathable==0.5.0b2
pkg_resources==0.0.0
pyrsistent==0.20.0
PyYAML==6.0.3
referencing==0.36.2
rfc3339-validator==0.1.4
rpds-py==0.27.1
six==1.17.0
typing_extensions==4.15.0

chenz-svsarrazin avatar Nov 20 '25 11:11 chenz-svsarrazin