Skip to content

Commit

Permalink
fix(apispec): validate only if request is actually json and not empty.
Browse files Browse the repository at this point in the history
werkzeug 2.1.0 request.get_json raises if not json or if body is empty.

Supports Werkzeug 2.1.0: https://werkzeug.palletsprojects.com/en/2.1.x/changes/\#version-2-1-0.
  • Loading branch information
desaintmartin committed Mar 29, 2022
1 parent f89f083 commit 33e1e5e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ Changelog

All notable changes to this project will be documented in this file.

`0.46.1`_ -- 2022-03-28
-----------------------
Fixed
^^^^^
* apisepc: validate only if request is actually json and not empty.
* tests: test_rabbitmq_cli: use test rabbitmq_broker instead of real rabbitmq broker.

`0.46.0`_ -- 2022-03-28
-----------------------
Changed
Expand Down
2 changes: 1 addition & 1 deletion remoulade/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@
"set_scheduler",
]

__version__ = "0.46.0"
__version__ = "0.46.1"
6 changes: 5 additions & 1 deletion remoulade/api/apispec.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
def validate_schema(schema):
def decorator(func):
def wrapper(*args, **kwargs):
res = schema().load(request.get_json() or {})
if request.is_json and request.content_length and request.content_length > 0:
body = request.get_json()
else:
body = {}
res = schema().load(body)
return func(*args, **res, **kwargs)

return use_kwargs(schema, apply=False)(update_wrapper(wrapper, func))
Expand Down

0 comments on commit 33e1e5e

Please sign in to comment.