Skip to content
Snippets Groups Projects
Verified Commit 7a1a4d6b authored by David Hoese's avatar David Hoese
Browse files

Move data API order check early on in the request handling

parent a0c7e41d
No related branches found
No related tags found
No related merge requests found
......@@ -208,11 +208,6 @@ def handle_csv(frame, epoch, response_info, formatting_kwargs):
def handle_json(frame, epoch, response_info, formatting_kwargs):
package = {}
order = formatting_kwargs.get("order", "columns")
if order not in ("column", "row"):
# bad order
frame = None
response_info["code"], response_info["message"] = data_responses.ERROR_MESSAGES["bad_order"]
response_info["status"] = "error"
code = response_info.get("code", 200)
if frame is not None and not frame.empty:
......@@ -340,6 +335,9 @@ def get_format_handler(fmt: str, formatting_kwargs: dict) -> Callable | tuple:
if fmt not in RESPONSE_HANDLERS:
raise BadHandlerFormat(bad_format=fmt)
handler_func = RESPONSE_HANDLERS[fmt]
if formatting_kwargs.get("order") not in ("column", "row"):
# bad order
raise create_formatted_error(partial(handler_func, formatting_kwargs={}), "bad_order")
return partial(handler_func, formatting_kwargs=formatting_kwargs)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment