openapi_spec_validator hands on create_spec on jsonschema 4.0.1

Open
#131 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
python
Domain
api

Research direction

Start by reproducing the hang through openapi_core/spec/shortcuts.py:create_spec with jsonschema 4.0.1, then compare the behavior with version 3.2.0 using the validator stack shown in the report. Trace the interaction across openapi_spec_validator/validators.py, decorators.py, and jsonschema's iter_errors; done means create_spec returns without recursive looping and the regression is covered by a test.

Written by the indexing model from the issue text.

Description

The code appears to enter into a recursive loop within jsonschema 4.0.1, a work around for now is reverting back to jsonschema 3.2.0 and the hang no longer happens.

`Package Version


apispec 5.1.1
apispec-oneofschema 3.0.0
asserts 0.11.1
attrs 21.2.0
azure-common 1.1.27
azure-core 1.19.0
azure-identity 1.6.1
azure-keyvault-secrets 4.3.0
backcall 0.2.0
bandit 1.7.0
certifi 2021.5.30
cffi 1.14.6
charset-normalizer 2.0.6
cryptography 35.0.0
decorator 5.1.0
dictpath 0.1.3
dnspython 1.16.0
eventlet 0.30.2
falcon 2.0.0
falcon-apispec 0.4.0
falcon-swagger-ui 1.2.1
flake8 3.9.2
flake8-broken-line 0.3.0
flake8-bugbear 21.9.2
flake8-debugger 4.0.0
flake8-polyfill 1.0.2
flake8-tidy-imports 4.4.1
gitdb 4.0.7
GitPython 3.1.24
goals-app 0.1
greenlet 1.1.2
gunicorn 20.1.0
idna 3.2
iniconfig 1.1.1
ipdb 0.13.9
ipython 7.28.0
isodate 0.6.0
jedi 0.17.2
Jinja2 3.0.1
jsonschema 4.0.1
lazy-object-proxy 1.6.0
Mako 1.1.5
Markdown 3.3.4
MarkupSafe 2.0.1
marshmallow 3.13.0
marshmallow-oneofschema 3.0.1
matplotlib-inline 0.1.3
mccabe 0.6.1
mock 4.0.3
more-itertools 8.10.0
msal 1.14.0
msal-extensions 0.3.0
msrest 0.6.21
numpy 1.21.2
oauthlib 3.1.1
openapi-core 0.14.2
openapi-schema-validator 0.1.5
openapi-spec-validator 0.3.1
packaging 21.0
parse 1.19.0
parso 0.7.1
pbr 5.6.0
pdoc3 0.10.0
pep8-naming 0.12.1
pexpect 4.8.0
pickleshare 0.7.5
pip 19.3.1
pluggy 1.0.0
portalocker 1.7.1
prompt-toolkit 3.0.20
ptyprocess 0.7.0
py 1.10.0
pycodestyle 2.7.0
pycparser 2.20
pyflakes 2.3.1
Pygments 2.10.0
PyJWT 2.1.0
pyodbc 4.0.32
pyparsing 2.4.7
pyrsistent 0.18.0
pytest 6.2.5
python-dateutil 2.8.2
PyYAML 5.4.1
requests 2.26.0
requests-oauthlib 1.3.0
requests-toolbelt 0.9.1
seqlog 0.3.20
setuptools 41.6.0
six 1.16.0
smmap 4.0.0
stevedore 3.4.0
toml 0.10.2
traitlets 5.1.0
typing-extensions 3.10.0.2
urllib3 1.26.7
wcwidth 0.2.5
Werkzeug 2.0.1 `

File "/usr/local/lib/python3.8/site-packages/openapi_core/spec/shortcuts.py", line 16, in create_spec openapi_v3_spec_validator.validate(spec_dict, spec_url=spec_url) File "/usr/local/lib/python3.8/site-packages/openapi_spec_validator/validators.py", line 49, in validate for err in self.iter_errors(spec, spec_url=spec_url): File "/usr/local/lib/python3.8/site-packages/openapi_spec_validator/decorators.py", line 59, in wrapper for err in errors: File "/usr/local/lib/python3.8/site-packages/openapi_spec_validator/validators.py", line 58, in iter_errors for err in validator.iter_errors(spec): File "/usr/local/lib/python3.8/site-packages/jsonschema/validators.py", line 224, in iter_errors for error in errors: File "/usr/local/lib/python3.8/site-packages/openapi_spec_validator/decorators.py", line 23, in wrapped for res in func(validator, schema_element, instance, schema): File "/usr/local/lib/python3.8/site-packages/jsonschema/_validators.py", line 329, in properties yield from validator.descend( File "/usr/local/lib/python3.8/site-packages/jsonschema/validators.py", line 240, in descend for error in self.evolve(schema=schema).iter_errors(instance): File "/usr/local/lib/python3.8/site-packages/jsonschema/validators.py", line 224, in iter_errors for error in errors: File "/usr/local/lib/python3.8/site-packages/openapi_spec_validator/decorators.py", line 23, in wrapped for res in func(validator, schema_element, instance, schema): File "/usr/local/lib/python3.8/site-packages/jsonschema/_validators.py", line 295, in ref yield from validator.descend(instance, resolved) File "/usr/local/lib/python3.8/site-packages/jsonschema/validators.py", line 240, in descend for error in self.evolve(schema=schema).iter_errors(instance): File "/usr/local/lib/python3.8/site-packages/jsonschema/validators.py", line 224, in iter_errors for error in errors: File "/usr/local/lib/python3.8/site-packages/openapi_spec_validator/decorators.py", line 23, in wrapped for res in func(validator, schema_element, instance, schema): File "/usr/local/lib/python3.8/site-packages/jsonschema/_validators.py", line 25, in patternProperties yield from validator.descend( File "/usr/local/lib/python3.8/site-packages/jsonschema/validators.py", line 240, in descend for error in self.evolve(schema=schema).iter_errors(instance): File "/usr/local/lib/python3.8/site-packages/jsonschema/validators.py", line 224, in iter_errors for error in errors: File "/usr/local/lib/python3.8/site-packages/openapi_spec_validator/decorators.py", line 23, in wrapped for res in func(validator, schema_element, instance, schema): File "/usr/local/lib/python3.8/site-packages/jsonschema/_validators.py", line 295, in ref yield from validator.descend(instance, resolved) File "/usr/local/lib/python3.8/site-packages/jsonschema/validators.py", line 240, in descend for error in self.evolve(schema=schema).iter_errors(instance): File "/usr/local/lib/python3.8/site-packages/jsonschema/validators.py", line 224, in iter_errors

Dominant language
Python
Stars
409
Forks
73
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python-openapi/openapi-spec-validator

All issues in python-openapi/openapi-spec-validator

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.