mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 18:01:08 -05:00
fix failed sanitise flow
the move from virus scan to validation failed function was called with the wrong variables, and had some internal logic that was slightly wrong. Also, Don't use `update_notification_by_id` for notifications if they are not in `created`, `sending`, `pending`, or `sent`. It silently doesn't update them. I didn't want to do a deeper investigation into the reasons behind this terrifying state machine as part of this commit so I just changed the functions to call `dao_update_notification` manually
This commit is contained in:
@@ -27,8 +27,9 @@ from app.letters.utils import (
|
||||
get_reference_from_filename,
|
||||
get_folder_name,
|
||||
upload_letter_pdf,
|
||||
move_failed_pdf,
|
||||
ScanErrorType,
|
||||
move_failed_pdf,
|
||||
move_scan_to_invalid_pdf_bucket,
|
||||
move_error_pdf_to_scan_bucket,
|
||||
get_file_names_from_error_bucket
|
||||
)
|
||||
@@ -41,8 +42,6 @@ from app.models import (
|
||||
NOTIFICATION_VALIDATION_FAILED
|
||||
)
|
||||
|
||||
from app.letters.utils import move_scan_to_invalid_pdf_bucket
|
||||
|
||||
|
||||
@notify_celery.task(bind=True, name="create-letters-pdf", max_retries=15, default_retry_delay=300)
|
||||
@statsd(namespace="tasks")
|
||||
@@ -194,8 +193,11 @@ def process_virus_scan_passed(self, filename):
|
||||
|
||||
if not new_pdf:
|
||||
current_app.logger.info('Invalid precompiled pdf received {} ({})'.format(notification.id, filename))
|
||||
update_notification_status_by_id(notification.id, NOTIFICATION_VALIDATION_FAILED)
|
||||
move_scan_to_invalid_pdf_bucket(scan_pdf_object)
|
||||
|
||||
notification.status = NOTIFICATION_VALIDATION_FAILED
|
||||
dao_update_notification(notification)
|
||||
|
||||
move_scan_to_invalid_pdf_bucket(filename)
|
||||
scan_pdf_object.delete()
|
||||
return
|
||||
else:
|
||||
@@ -257,7 +259,9 @@ def _sanitise_precomiled_pdf(self, notification, precompiled_pdf):
|
||||
current_app.logger.exception(
|
||||
"RETRY FAILED: sanitise_precomiled_pdf failed for notification {}".format(notification.id),
|
||||
)
|
||||
update_notification_status_by_id(notification.id, NOTIFICATION_TECHNICAL_FAILURE)
|
||||
|
||||
notification.status = NOTIFICATION_TECHNICAL_FAILURE
|
||||
dao_update_notification(notification)
|
||||
raise
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user