mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 02:11:11 -05:00
Refuse to process invalid files
Since the admin app won’t be checking the metadata when it starts a job now it’s possible that someone could make a post request which attempts to start a job for an invalid file. This commit adds a check to make sure that can’t happen. This is more of an extra safety thing, rather than something that the admin app or a user will see.
This commit is contained in:
@@ -127,11 +127,15 @@ def create_job(service_id):
|
||||
except KeyError:
|
||||
raise InvalidRequest({'id': ['Missing data for required field.']}, status_code=400)
|
||||
|
||||
data['template'] = data.pop('template_id')
|
||||
template = dao_get_template_by_id(data['template'])
|
||||
|
||||
if template.template_type == LETTER_TYPE and service.restricted:
|
||||
raise InvalidRequest("Create letter job is not allowed for service in trial mode ", 403)
|
||||
|
||||
if data.get('valid') != 'True':
|
||||
raise InvalidRequest("File is not valid, can't create job", 400)
|
||||
|
||||
errors = unarchived_template_schema.validate({'archived': template.archived})
|
||||
|
||||
if errors:
|
||||
|
||||
Reference in New Issue
Block a user