aboutsummaryrefslogtreecommitdiffstats
path: root/python/fatcat_web
diff options
context:
space:
mode:
authorMartin Czygan <martin@archive.org>2020-03-26 22:38:14 +0000
committerMartin Czygan <martin@archive.org>2020-03-26 22:38:14 +0000
commit5c4f5114b4dfeb7a5deca20d460c9fc5759a922a (patch)
treee0e4d29408214bcd81a12bdc1f9f9a8706944458 /python/fatcat_web
parentea241c0718407285774bff85e4b3b99aed0b9186 (diff)
parentb9657b39f4061e4cf870fa253c5665ab5ad60cc6 (diff)
downloadfatcat-5c4f5114b4dfeb7a5deca20d460c9fc5759a922a.tar.gz
fatcat-5c4f5114b4dfeb7a5deca20d460c9fc5759a922a.zip
Merge branch 'bnewbold-400-bad-revisions' into 'master'
catch ApiValueError in some generic API calls See merge request webgroup/fatcat!35
Diffstat (limited to 'python/fatcat_web')
-rw-r--r--python/fatcat_web/entity_helpers.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/python/fatcat_web/entity_helpers.py b/python/fatcat_web/entity_helpers.py
index 009f6160..b04be55c 100644
--- a/python/fatcat_web/entity_helpers.py
+++ b/python/fatcat_web/entity_helpers.py
@@ -1,6 +1,6 @@
from flask import abort
-from fatcat_openapi_client.rest import ApiException
+from fatcat_openapi_client.rest import ApiException, ApiValueError
from fatcat_tools.transforms import *
from fatcat_web import app, api
from fatcat_web.search import get_elastic_container_stats, get_elastic_container_random_releases
@@ -123,6 +123,8 @@ def generic_get_entity(entity_type, ident):
raise NotImplementedError
except ApiException as ae:
abort(ae.status)
+ except ApiValueError:
+ abort(400)
def generic_get_entity_revision(entity_type, revision_id):
try:
@@ -144,6 +146,8 @@ def generic_get_entity_revision(entity_type, revision_id):
raise NotImplementedError
except ApiException as ae:
abort(ae.status)
+ except ApiValueError:
+ abort(400)
def generic_get_editgroup_entity(editgroup, entity_type, ident):
if entity_type == 'container':
@@ -172,6 +176,12 @@ def generic_get_editgroup_entity(editgroup, entity_type, ident):
# couldn't find relevent edit in this editgroup
abort(404)
- entity = generic_get_entity_revision(entity_type, revision_id)
+ try:
+ entity = generic_get_entity_revision(entity_type, revision_id)
+ except ApiException as ae:
+ abort(ae.status)
+ except ApiValueError:
+ abort(400)
+
entity.ident = ident
return entity, edit