fix: Prevent locals() from polluting player PATCH data dict #4
No reviewers
Labels
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/major-domo-database#4
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/locals-pollution-patch-endpoint"
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?
CRITICAL BUG FIX - Root cause of Player.data AttributeError
Problem:
The PATCH endpoint was calling locals() AFTER creating data = {}, causing
locals_dict to capture 'data' and 'locals_dict' as variables. The loop then
added these to the data dict itself, resulting in:
data = {'team_id': 549, 'demotion_week': 7, 'data': {}, 'locals_dict': {...}}
When Peewee executed Player.update(**data), it tried to set Player.data = {},
but Player model has no 'data' field, causing AttributeError.
Solution:
This ensures only actual player field parameters are included in the update.
Version: 2.5.2 → 2.5.3
Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com
CRITICAL BUG FIX - Root cause of Player.data AttributeError Problem: The PATCH endpoint was calling locals() AFTER creating data = {}, causing locals_dict to capture 'data' and 'locals_dict' as variables. The loop then added these to the data dict itself, resulting in: data = {'team_id': 549, 'demotion_week': 7, 'data': {}, 'locals_dict': {...}} When Peewee executed Player.update(**data), it tried to set Player.data = {}, but Player model has no 'data' field, causing AttributeError. Solution: 1. Call locals() BEFORE creating data dict 2. Exclude 'locals_dict' from the filter (along with 'player_id', 'token') This ensures only actual player field parameters are included in the update. Version: 2.5.2 → 2.5.3 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>