|
Some checks failed
Build Docker Image / build (pull_request) Failing after 19s
Added robust validation to handle spreadsheet errors and invalid data when reading pitching decisions from scorecards. Problem: - POST /api/v3/decisions was failing with 422 errors - Google Sheets cells containing "#N/A" were passed directly to API - API correctly rejected invalid team_id values like "#N/A" string - No validation of integer fields or required fields Root Cause: - sheets_service.py:read_pitching_decisions() read values without validation or type checking - Spreadsheet formula errors (#N/A, #REF!, etc.) passed through - Invalid data types not caught until API validation failed Solution: 1. Added _is_spreadsheet_error() to detect formula errors 2. Added _sanitize_int_field() to validate and convert integers 3. Enhanced read_pitching_decisions() to: - Detect and skip rows with spreadsheet errors - Validate integer fields (pitcher_id, team_id, etc.) - Ensure required fields (pitcher_id, team_id) are present - Log warnings for invalid data with row numbers - Only return valid, sanitized decision data Impact: - Prevents 422 errors from bad spreadsheet data - Provides clear warnings in logs when data is invalid - Gracefully skips invalid rows instead of crashing - Helps identify scorecard data entry errors Testing: - Handles #N/A, #REF!, #VALUE!, #DIV/0! and other errors - Converts "123.0" strings to integers correctly - Validates required fields before sending to API - Logs row numbers for debugging bad data Production logs showed: "Input should be a valid integer, unable to parse string as an integer", input: "#N/A" for team_id field Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| base_service.py | ||
| chart_service.py | ||
| CLAUDE.md | ||
| custom_commands_service.py | ||
| decision_service.py | ||
| draft_list_service.py | ||
| draft_pick_service.py | ||
| draft_service.py | ||
| draft_sheet_service.py | ||
| game_service.py | ||
| giphy_service.py | ||
| help_commands_service.py | ||
| injury_service.py | ||
| league_service.py | ||
| play_service.py | ||
| player_service.py | ||
| roster_service.py | ||
| schedule_service.py | ||
| scorebug_service.py | ||
| sheets_service.py | ||
| standings_service.py | ||
| stats_service.py | ||
| team_service.py | ||
| trade_builder.py | ||
| transaction_builder.py | ||
| transaction_service.py | ||