diff --git a/app/main/views/notifications.py b/app/main/views/notifications.py index 158c02635..04c20bbe9 100644 --- a/app/main/views/notifications.py +++ b/app/main/views/notifications.py @@ -81,9 +81,15 @@ def view_notification(service_id, notification_id): else: page_count = get_page_count_for_letter(notification['template'], values=personalisation) if page_count and page_count > LETTER_MAX_PAGE_COUNT: - # when a templated letter is sent via the api and the personalisation pushes - # the page count over 10 we need to validate that. The letter is not in validation failed, - # this will enable us to show the error. Perhaps there is a better way to do this. + # We check page count here to show the right error message for a letter that is too long. + # Another way to do this would be to get the status and error message from letter metadata. + # This would be a significant amount of work though, out of scope for this bug fix. + # This is because currently we do not pull the letter from S3 when showing preview. + # Instead, we generate letter preview based on the letter template and personalisation. + # Additionally, when a templated letter is sent via the api and the personalisation pushes the + # page count over 10 pages, it takes a while for validation status to come through. + # Checking page count here will enable us to show the error message even if the letter is not + # fully processed yet. error_message = get_letter_validation_error( "letter-too-long", [1], page_count )