Skip to content

fix: download entries CSV crashes with IndexError when round has no entries #531

@lgelauff

Description

@lgelauff

Bug

download_round_entries_csv raises an unhandled IndexError when the round has no entries, producing a raw internal server error page instead of a meaningful message.

Traceback

IndexError: list index out of range
montage/admin_endpoints.py, line 294
csv_fieldnames = sorted(entry_infos[0].keys())

When it happens

Any attempt to download the entries CSV for a round that has no entries — for example:

  • Round 1 before images have been imported
  • A round where all entries were disqualified

Root cause

download_round_entries_csv derives CSV field names from the first element of entry_infos. If the list is empty, entry_infos[0] crashes. There is no guard for this case.

Fix

Add an early return before line 114 in admin_endpoints.py:

if not entry_infos:
    raise InvalidAction('no entries in round, cannot export CSV')

Confirmed on

montage-beta

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions