mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 14:09:20 -04:00
Don’t 500 when a CSV is missing rows
> When the CSV is missing the header row, we get an error and the user > will see "Sorry, we are experiencing technical difficulties..." > > We should return a better error message for the user. – https://www.pivotaltracker.com/story/show/140668615 This was caused by an attempt to access the `first_recipient` variable before it was assigned. It would only be assigned when there was at least one row in the file. Fixing this means doing two things: - defaulting `first_recipient` to be `None` before looking in the file - adding an error message for when we can’t extract any rows out of the file (which is more nuanced than the file just being completely empty) (There’s a nasty `sort` in the Jinja template because when there are no rows in the file the order of the required column headers is not deterministic.)
This commit is contained in:
@@ -138,7 +138,23 @@ def test_upload_csvfile_with_errors_shows_check_page_with_errors(
|
||||
'It doesn’t have a column called ‘name’. '
|
||||
'Skip to file contents'
|
||||
)
|
||||
)
|
||||
),
|
||||
(
|
||||
"+447700900986",
|
||||
(
|
||||
'Your file is missing some rows '
|
||||
'It needs at least one row of data, and columns called ‘name’ and ‘phone number’. '
|
||||
'Skip to file contents'
|
||||
)
|
||||
),
|
||||
(
|
||||
"",
|
||||
(
|
||||
'Your file is missing some rows '
|
||||
'It needs at least one row of data, and columns called ‘name’ and ‘phone number’. '
|
||||
'Skip to file contents'
|
||||
)
|
||||
),
|
||||
])
|
||||
def test_upload_csvfile_with_missing_columns_shows_error(
|
||||
logged_in_client,
|
||||
|
||||
Reference in New Issue
Block a user