Skip to content

fix: use submitted_file instead of undefined filename in uploadXls error response#362

Open
Vinay152003 wants to merge 2 commits intoEAPD-DRB:mainfrom
Vinay152003:fix/uploadxls-undefined-filename
Open

fix: use submitted_file instead of undefined filename in uploadXls error response#362
Vinay152003 wants to merge 2 commits intoEAPD-DRB:mainfrom
Vinay152003:fix/uploadxls-undefined-filename

Conversation

@Vinay152003
Copy link
Copy Markdown

@Vinay152003 Vinay152003 commented Mar 23, 2026

Summary

Fixes a NameError crash in uploadXls() when an uploaded file has an invalid extension.

Root cause: The filename variable is only defined inside the if branch (via secure_filename()), but the else branch (invalid extension) also references filename on line 644. If the first uploaded file has an invalid extension, filename is never assigned, causing the server to crash.

Changes

  • API/Routes/Upload/UploadRoute.py line 644: filenamesubmitted_file

Test plan

  • Upload an .xlsx file — verify success response includes correct template name
  • Upload a non-xlsx file (e.g., .txt) — verify error response returns without crash
  • Upload multiple files with mix of valid and invalid extensions — verify all responses are correct

Fixes #360

@SeaCelo

…ror response

The filename variable is only defined inside the if branch when
the file extension is valid. In the else branch (invalid extension),
referencing filename causes a NameError crash. Using submitted_file
instead, which is always defined from the request, fixes the crash.

Fixes EAPD-DRB#360
@github-actions github-actions bot added the needs-intake-fix PR intake structure needs maintainer follow-up label Mar 23, 2026
@Vinay152003
Copy link
Copy Markdown
Author

@SeaCelo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-intake-fix PR intake structure needs maintainer follow-up

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] uploadXls() references undefined filename variable when file extension is invalid

1 participant