fix: handle trying to decode invalid JSON (#34167)

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
Akhil Narang 2025-09-29 11:07:53 +05:30 committed by GitHub
parent 72b20fa52b
commit 03dcc3819d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -321,7 +321,10 @@ def set_authenticate_headers(response: Response):
def make_form_dict(request: Request):
request_data = request.get_data(as_text=True)
if request_data and request.is_json:
args = orjson.loads(request_data)
try:
args = orjson.loads(request_data)
except orjson.JSONDecodeError:
frappe.throw(_("Invalid request body"), frappe.DataError)
else:
args = {}
args.update(request.args or {})