benji
benji copied to clipboard
fix(restapi): fix API ignoring query string parameters for GET requests
Hello, it's me again 🙂
Webargs 6.0 changed the behaviour of data location lookups to be single-source instead of a union of all locations, the default now is json and it only looks in there.
This broke the /versions endpoint of the rest-api, because it expects filter_expression and include_blocks as query string parameters: GET method does not have a request body (json) in its specification, so only query string is available.
Inside the route-decorated function call, the following state can be observed:
request.body.getvalue(): filter_expression=123&include_blocks=true
locals(): {'self': <benji.restapi.RestAPI object at 0x7f5a23fc6280>, 'filter_expression': None, 'include_blocks': False}
This change fixes this problem by forcing webargs to look into the query string parameters if it is a GET request, falling back to the default json otherwise.