From 31b14ec7095b917a6b6c483d662d8c570861ff48 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Wed, 11 Feb 2026 15:54:39 -0600 Subject: [PATCH 1/2] fix: Replace fragile locals() pattern in PATCH endpoints with explicit field dicts The teams PATCH endpoint included the `data` variable itself when building the update dict via locals(), causing Peewee to fail with "type object 'Team' has no attribute 'data'". The players endpoint had the same pattern with a workaround that was order-dependent. Co-Authored-By: Claude Opus 4.6 --- app/routers_v3/players.py | 20 ++++++++++++++------ app/routers_v3/teams.py | 16 +++++++++++----- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/app/routers_v3/players.py b/app/routers_v3/players.py index 343a4ce..5136425 100644 --- a/app/routers_v3/players.py +++ b/app/routers_v3/players.py @@ -117,12 +117,20 @@ async def patch_player( ): """Patch a player (partial update).""" # Build dict of provided fields - # IMPORTANT: Capture locals() BEFORE creating data dict to avoid including 'data' itself - locals_dict = locals() - data = {} - for key, value in locals_dict.items(): - if key not in ('player_id', 'token', 'locals_dict') and value is not None: - data[key] = value + data = { + key: value + for key, value in { + 'name': name, 'wara': wara, 'image': image, 'image2': image2, + 'team_id': team_id, 'season': season, + 'pos_1': pos_1, 'pos_2': pos_2, 'pos_3': pos_3, 'pos_4': pos_4, + 'pos_5': pos_5, 'pos_6': pos_6, 'pos_7': pos_7, 'pos_8': pos_8, + 'vanity_card': vanity_card, 'headshot': headshot, + 'il_return': il_return, 'demotion_week': demotion_week, + 'strat_code': strat_code, 'bbref_id': bbref_id, + 'injury_rating': injury_rating, 'sbaref_id': sbaref_id, + }.items() + if value is not None + } return PlayerService.patch_player(player_id, data, token) diff --git a/app/routers_v3/teams.py b/app/routers_v3/teams.py index 5409362..f64d6a1 100644 --- a/app/routers_v3/teams.py +++ b/app/routers_v3/teams.py @@ -92,11 +92,17 @@ async def patch_team( ): """Patch a team (partial update).""" # Build dict of provided fields - data = {} - locals_dict = locals() - for key, value in locals_dict.items(): - if key not in ('team_id', 'token') and value is not None: - data[key] = value + data = { + key: value + for key, value in { + 'manager1_id': manager1_id, 'manager2_id': manager2_id, + 'gmid': gmid, 'gmid2': gmid2, 'mascot': mascot, + 'stadium': stadium, 'thumbnail': thumbnail, 'color': color, + 'abbrev': abbrev, 'sname': sname, 'lname': lname, + 'dice_color': dice_color, 'division_id': division_id, + }.items() + if value is not None + } return TeamService.update_team(team_id, data, token) -- 2.25.1 From e257a96a8a07b69be5e503786e785214ea071de4 Mon Sep 17 00:00:00 2001 From: cal Date: Wed, 11 Feb 2026 21:55:34 +0000 Subject: [PATCH 2/2] Update VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index e70b452..6a6a3d8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.6.0 +2.6.1 -- 2.25.1