fix: prefix trade validation errors with team abbreviation #71

Merged
cal merged 2 commits from fix/trade-errors-show-team-abbrev into next-release 2026-03-10 15:46:44 +00:00
Owner

Summary

  • Trade validation errors, warnings, and suggestions from roster-level checks are now prefixed with the team abbreviation (e.g. [BSG] Too many ML players)
  • Helps users identify which team each validation issue applies to during multi-team trades
  • Added team_abbrevs dict to TradeValidationResult populated during validate_trade()

Test plan

  • Updated test_validation_result_aggregation to verify [TM1]/[TM2] prefixes on roster-level messages
  • All 36 trade builder tests pass
  • Teams with no abbreviation mapping fall back to [???]

🤖 Generated with Claude Code

## Summary - Trade validation errors, warnings, and suggestions from roster-level checks are now prefixed with the team abbreviation (e.g. `[BSG] Too many ML players`) - Helps users identify which team each validation issue applies to during multi-team trades - Added `team_abbrevs` dict to `TradeValidationResult` populated during `validate_trade()` ## Test plan - [x] Updated `test_validation_result_aggregation` to verify `[TM1]`/`[TM2]` prefixes on roster-level messages - [x] All 36 trade builder tests pass - [x] Teams with no abbreviation mapping fall back to `[???]` 🤖 Generated with [Claude Code](https://claude.com/claude-code)
cal added 1 commit 2026-03-08 16:37:56 +00:00
fix: prefix trade validation errors with team abbreviation
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m5s
8ee35e564c
Roster-level errors, warnings, and suggestions now display as
"[BSG] Too many ML players" so users know which team each issue
applies to.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
cal changed target branch from main to next-release 2026-03-08 16:43:36 +00:00
Claude added the
ai-reviewing
label 2026-03-08 16:45:36 +00:00
Claude reviewed 2026-03-08 16:46:44 +00:00
Claude left a comment
Collaborator

AI Code Review

Files Reviewed

  • services/trade_builder.py (modified)
  • tests/test_services_trade_builder.py (modified)

Findings

Correctness

  • team_abbrevs[team_id] is populated outside the if team_id in self._team_builders guard at line 463, so all participants get an entry regardless of whether they have a builder. This is intentional and correct — the properties only iterate over participant_validations.items(), so extra entries in team_abbrevs are harmless and the fallback "???" is an unreachable-in-practice safety net.
  • The three all_errors/all_warnings/all_suggestions properties are symmetric and correct. Trade-level messages (from trade_errors, trade_warnings, trade_suggestions) are not prefixed; only roster-level messages from participant_validations are, which matches the stated intent.
  • Initiating team edge case: the initiating team is added in __init__ without a builder. If validate_trade() is called before moves are added, that team has no participant_validations entry, so the prefix logic never runs for them — correct behaviour.

Security

  • No issues. This is a pure string-formatting change for display purposes.

Style & Conventions

  • Bulk reformatting of existing test code (single→double quotes, trailing commas) is consistent with the project's ruff hook behaviour and not a concern.
  • The new team_abbrevs dict field is typed correctly (Dict[int, str]) and initialized in __init__ alongside the other dicts.

Suggestions

  • The "???" fallback is advertised in the PR body but not covered by a test. A short test exercising a participant_validations entry with no corresponding team_abbrevs key would lock in that contract. Not a blocker.

Verdict: APPROVED

Clean, minimal, and correct. Logic is sound, tests are updated and passing (36/36), and the change delivers the stated UX improvement for multi-team trade error attribution.


Automated review by Claude PR Reviewer

## AI Code Review ### Files Reviewed - `services/trade_builder.py` (modified) - `tests/test_services_trade_builder.py` (modified) ### Findings #### Correctness - `team_abbrevs[team_id]` is populated **outside** the `if team_id in self._team_builders` guard at line 463, so all participants get an entry regardless of whether they have a builder. This is intentional and correct — the properties only iterate over `participant_validations.items()`, so extra entries in `team_abbrevs` are harmless and the fallback `"???"` is an unreachable-in-practice safety net. - The three `all_errors`/`all_warnings`/`all_suggestions` properties are symmetric and correct. Trade-level messages (from `trade_errors`, `trade_warnings`, `trade_suggestions`) are not prefixed; only roster-level messages from `participant_validations` are, which matches the stated intent. - Initiating team edge case: the initiating team is added in `__init__` without a builder. If `validate_trade()` is called before moves are added, that team has no `participant_validations` entry, so the prefix logic never runs for them — correct behaviour. #### Security - No issues. This is a pure string-formatting change for display purposes. #### Style & Conventions - Bulk reformatting of existing test code (single→double quotes, trailing commas) is consistent with the project's ruff hook behaviour and not a concern. - The new `team_abbrevs` dict field is typed correctly (`Dict[int, str]`) and initialized in `__init__` alongside the other dicts. #### Suggestions - The `"???"` fallback is advertised in the PR body but not covered by a test. A short test exercising a `participant_validations` entry with no corresponding `team_abbrevs` key would lock in that contract. Not a blocker. ### Verdict: APPROVED Clean, minimal, and correct. Logic is sound, tests are updated and passing (36/36), and the change delivers the stated UX improvement for multi-team trade error attribution. --- *Automated review by Claude PR Reviewer*
Claude added
ai-reviewed
and removed
ai-reviewing
labels 2026-03-08 16:47:18 +00:00
cal added 1 commit 2026-03-08 16:48:19 +00:00
Trade validation now automatically fetches the current week from
league_service and validates against next week's projected roster
(including pending transactions), matching /dropadd behavior.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
cal merged commit bebe25b9dd into next-release 2026-03-10 15:46:44 +00:00
cal deleted branch fix/trade-errors-show-team-abbrev 2026-03-10 15:46:45 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 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-v2#71
No description provided.