Skip to content

fix: Improve CSV badge awarding with validation and error reporting#875

Open
Marvinrose wants to merge 1 commit intofedora-infra:swatantryafrom
Marvinrose:feature/csv-badge-awarding-fixes-swatantrya
Open

fix: Improve CSV badge awarding with validation and error reporting#875
Marvinrose wants to merge 1 commit intofedora-infra:swatantryafrom
Marvinrose:feature/csv-badge-awarding-fixes-swatantrya

Conversation

@Marvinrose
Copy link
Copy Markdown

@Marvinrose Marvinrose commented Mar 28, 2026

Fix: CSV badge awarding with validation and error reporting

Fixes #348

Problem

The award_from_csv endpoint existed to allow admins to award badges in bulk via CSV upload, but had a TODO requesting validation and feedback that was never implemented.

The original code had file validation issues, bytes read as strings, silent failures with no admin feedback..

Fix

To fix this issue, all i did was:

  • Validate the file is present and has a filename before processing
  • Decode each line from bytes to string explicitly using UTF-8
  • Normalise column order: both email,badge_id and badge_id,email are accepted
  • Validate badge existence before attempting to award
  • Auto-create users who don't exist, preserving original behaviour and report which users were created
  • Track and report already-awarded badges instead of silently skipping
  • Flash a complete summary after processing, covering all outcomes

Assisted-by: Claude (Anthropic) - used for reference on bytes decoding.

Signed-off-by: Chibuezem Marvinrose <rozzeymarvin32@gmail.com>
@Marvinrose Marvinrose force-pushed the feature/csv-badge-awarding-fixes-swatantrya branch from fb9f0ee to 75c0780 Compare April 5, 2026 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant