Skip to content

fix: improve CSV badge awarding with validation and error reporting#828

Closed
Marvinrose wants to merge 2 commits intofedora-infra:developfrom
Marvinrose:feature/csv-badge-awarding-fixes
Closed

fix: improve CSV badge awarding with validation and error reporting#828
Marvinrose wants to merge 2 commits intofedora-infra:developfrom
Marvinrose:feature/csv-badge-awarding-fixes

Conversation

@Marvinrose
Copy link
Copy Markdown

@Marvinrose Marvinrose commented Mar 22, 2026

Fix: CSV badge awarding with validation and error reporting

Fixes #348

Problem

The existing award_from_csv() had multiple issues:

  • In Python 3, file lines are bytes not str, causing .split(",") to silently fail
  • No validation for missing or empty file uploads
  • No feedback to the admin on what happened, the original requester specifically asked to know which accounts weren't found
  • No handling of malformed CSV lines

Changes

  • Added .decode("utf-8") fix for Python 3 bytes handling
  • Added file presence and empty filename validation
  • Added detailed summary flash messages covering:
    • Successful awards count
    • Users that didn't exist and were auto-created
    • Skipped duplicates (already awarded)
    • Badge IDs not found in the system
    • Malformed lines that couldn't be parsed
  • Added tests

@Marvinrose
Copy link
Copy Markdown
Author

Closing this PR as it was targeting the wrong branch.
A new PR has been opened targeting the swatantrya branch instead: #875

@Marvinrose Marvinrose closed this Mar 28, 2026
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.

RFE: csv submission of badge awardees

1 participant