mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2024-12-23 00:59:59 +00:00
api: Invalid JSON is a client-side error
This commit is contained in:
parent
517f5c48e6
commit
aa0d7f702f
|
@ -85,7 +85,11 @@ def v2_api_upload():
|
||||||
request_data_field = flask.request.form.get('torrent_data')
|
request_data_field = flask.request.form.get('torrent_data')
|
||||||
if request_data_field is None:
|
if request_data_field is None:
|
||||||
return flask.jsonify({'errors': ['missing torrent_data field']}), 400
|
return flask.jsonify({'errors': ['missing torrent_data field']}), 400
|
||||||
|
|
||||||
|
try:
|
||||||
request_data = json.loads(request_data_field)
|
request_data = json.loads(request_data_field)
|
||||||
|
except json.decoder.JSONDecodeError:
|
||||||
|
return flask.jsonify({'errors': ['unable to parse valid JSON in torrent_data']}), 400
|
||||||
|
|
||||||
# Map api keys to upload form fields
|
# Map api keys to upload form fields
|
||||||
for key, default in UPLOAD_API_DEFAULTS.items():
|
for key, default in UPLOAD_API_DEFAULTS.items():
|
||||||
|
|
Loading…
Reference in a new issue