diff --git a/graph/fixes/fix-dynamic-roster-type-detection-in-trade-add-player-major-a272cc.md b/graph/fixes/fix-dynamic-roster-type-detection-in-trade-add-player-major-a272cc.md new file mode 100644 index 00000000000..a17e23a5b8e --- /dev/null +++ b/graph/fixes/fix-dynamic-roster-type-detection-in-trade-add-player-major-a272cc.md @@ -0,0 +1,29 @@ +--- +id: a272cc2a-d5c8-42a5-924a-dc6009bc5c3b +type: fix +title: "Fix: dynamic roster type detection in /trade add-player (major-domo-v2 #29)" +tags: [major-domo, discord-bot, python, fix, roster-type, trade, rostertype] +importance: 0.6 +confidence: 0.8 +created: "2026-03-03T06:08:10.984609+00:00" +updated: "2026-03-03T06:08:10.984609+00:00" +--- + +## Problem +`commands/transactions/trade.py` hardcoded `RosterType.MAJOR_LEAGUE` for both `from_roster` and `to_roster` in `/trade add-player`, making it impossible to trade players from/to Minor League rosters. + +## Root Cause +Lines 310–311 had placeholder comments acknowledging the limitation but never implemented dynamic detection. + +## Solution +- `from_roster`: use `player.team.roster_type()` if team object is populated; otherwise fetch via `team_service.get_team(player.team_id)` (search endpoint returns team as int, not nested object); fallback to MAJOR_LEAGUE for free agents. +- `to_roster`: use `dest_team.roster_type()` — dest_team is already a full Team object from `get_team_by_abbrev_with_validation()`. + +## Key Pattern +`Team.roster_type()` detects roster type from abbreviation suffix: `MIL` = MINOR_LEAGUE, `IL` = INJURED_LIST, ≤3 chars = MAJOR_LEAGUE. Has special handling for ambiguous `MIL` suffix (e.g. `BHMIL` = BHM+IL not BH+MIL). + +## Files Changed +- `commands/transactions/trade.py`: added `team_service` import; replaced hardcoded defaults + +## PR +https://git.manticorum.com/cal/major-domo-v2/pulls/61