fix: Prevent locals() from polluting player PATCH data dict #4

Merged
cal merged 1 commits from fix/locals-pollution-patch-endpoint into main 2026-02-04 21:00:24 +00:00
Owner

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

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>
cal added 1 commit 2026-02-04 21:00:19 +00:00
fix: Prevent locals() from polluting player PATCH data dict
Some checks failed
Build Docker Image / build (pull_request) Has been cancelled
6d36704f35
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>
cal merged commit ffcf0611b7 into main 2026-02-04 21:00:24 +00:00
cal deleted branch fix/locals-pollution-patch-endpoint 2026-02-04 21:00:28 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cal/major-domo-database#4
No description provided.