fix: photo upload/delete 500 for non-Member roles (UnboundLocalError) #143
No reviewers
Labels
No labels
architecture
backend
bug
ci
config
database
docker
documentation
duplicate
enhancement
frontend
help wanted
invalid
issue-25
issue-26
issue-42
issue-65
issue-67
issue-82
migrations
p0-critical
p1-high
p2-medium
p3-low
performance
quality
question
security
state-management
testing
timezone
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
fastie81/honbu-manager!143
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/photo-upload-unbound"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Prod logs (15 Oct) show
POST /api/members/<id>/photoreturning 500 withUnboundLocalError: cannot access local variable 'member_ops'.Cause
In
MemberPhoto.postand.delete,from app.container import member_opssits insideif role == 'Member':. That makesmember_opsfunction-local, so any non-Member role hits an unbound variable atsave_member_photo/delete_member_photo. The module already importsmember_opsat line 10.Fix
Remove the two inner imports (-2 lines). Same singleton object, so no behaviour change for Member role.
Tests
tests/unit/test_member_photo_unbound.py: upload + delete as Club Admin -> 200.test_club_switch_mockswitch_club_success_admin/member) - pre-existing on main, unrelated.