Gracefully handle bad ObjectId passed on URL
This commit is contained in:
parent
53aa0dae3b
commit
57375bd0c4
@ -445,7 +445,10 @@ def stream_to_gcs(project_id):
|
|||||||
uploaded_file = request.files['file']
|
uploaded_file = request.files['file']
|
||||||
|
|
||||||
projects = current_app.data.driver.db['projects']
|
projects = current_app.data.driver.db['projects']
|
||||||
|
try:
|
||||||
project = projects.find_one(ObjectId(project_id), projection={'_id': 1})
|
project = projects.find_one(ObjectId(project_id), projection={'_id': 1})
|
||||||
|
except InvalidId:
|
||||||
|
project = None
|
||||||
if not project:
|
if not project:
|
||||||
raise NotFound('Project %s does not exist' % project_id)
|
raise NotFound('Project %s does not exist' % project_id)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user