pgjones / quart-schema

Quart-Schema is a Quart extension that provides schema validation and auto-generated API documentation.
MIT License
76 stars 24 forks source link

KeyError: 'QUART_SCHEMA_CONVERT_CASING' #57

Closed sanderfoobar closed 12 months ago

sanderfoobar commented 1 year ago

Got a strange error in one of my apps:

[2023-09-08 00:18:09,216] ERROR in app: Exception on request POST /bla
Traceback (most recent call last):
  File "/home/foo/bar/venv/lib/python3.10/site-packages/quart/app.py", line 1650, in handle_request
    return await self.full_dispatch_request(request_context)
  File "/home/foo/bar/venv/lib/python3.10/site-packages/quart/app.py", line 1675, in full_dispatch_request
    result = await self.handle_user_exception(error)
  File "/home/foo/bar/venv/lib/python3.10/site-packages/quart/app.py", line 1107, in handle_user_exception
    raise error
  File "/home/foo/bar/venv/lib/python3.10/site-packages/quart/app.py", line 1673, in full_dispatch_request
    result = await self.dispatch_request(request_context)
  File "/home/foo/bar/venv/lib/python3.10/site-packages/quart/app.py", line 1718, in dispatch_request
    return await self.ensure_async(handler)(**request_.view_args)
  File "/home/foo/bar/venv/lib/python3.10/site-packages/quart_schema/validation.py", line 163, in wrapper
    if current_app.config["QUART_SCHEMA_CONVERT_CASING"]:
KeyError: 'QUART_SCHEMA_CONVERT_CASING'

Solved it by ensuring the key is present:

app = Quart(__name__)
app.config['QUART_SCHEMA_CONVERT_CASING'] = False

Should this be .get() ?

https://github.com/pgjones/quart-schema/blob/91e46e849507d80bdd952fec8fb0ddc4f3decba2/src/quart_schema/validation.py#L166C39-L166C39

pgjones commented 1 year ago

Are you initialising the extension?

app = Quart(__name__)
QuartSchema(app)
sanderfoobar commented 12 months ago

whoops, I did not