Major Domo v2 - Discord bot for Strat-o-Matic Baseball Association
Go to file
Cal Corum 92eb9055f1
Some checks failed
Build Docker Image / build (pull_request) Failing after 19s
fix: Validate and sanitize pitching decision data from Google Sheets
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>
2026-02-05 21:44:06 -06:00
.gitea/workflows Fix injury commands player.team None errors and add Gitea CI/CD 2026-02-05 14:16:22 -06:00
.vscode VS Code Settings 2025-11-06 21:50:47 -06:00
api CLAUDE: Add automated weekly transaction freeze/thaw system 2025-10-20 12:16:13 -05:00
commands Fix /player autocomplete timeout by using current season only 2026-02-05 20:45:09 -06:00
models Add draft pause/resume functionality 2025-12-11 19:58:37 -06:00
services fix: Validate and sanitize pitching decision data from Google Sheets 2026-02-05 21:44:06 -06:00
tasks Fix missing Optional import in transaction_freeze.py 2026-02-01 21:16:25 -06:00
tests Fix API parameter name: use 'demotion_week' instead of 'dem_week' 2026-02-01 21:27:52 -06:00
utils Fix custom command mentions not triggering notifications 2026-01-28 15:45:38 -06:00
views Add dem_week parameter to player team updates 2026-02-01 21:12:06 -06:00
.dockerignore Add debug directory to .gitignore and .dockerignore 2025-10-24 00:06:34 -05:00
.gitignore Draft pick service and draft helpers 2025-10-24 10:24:14 -05:00
bot.py Add dev-only loaded dice command for testing /ab rolls 2026-01-07 22:45:01 -06:00
CLAUDE.md Add production deployment documentation to CLAUDE.md 2026-01-20 13:40:55 -06:00
COMMAND_LIST.md CLAUDE: Add comprehensive scorecard submission system 2025-10-16 00:21:32 -05:00
config.py Add injury log posting and fix view interaction permissions 2025-12-19 00:08:11 -06:00
docker-compose.dev.yml CLAUDE: Add comprehensive Docker deployment infrastructure 2025-10-16 00:54:56 -05:00
docker-compose.yml Fix @requires_team decorator API error handling 2025-11-14 09:31:14 -06:00
DOCKER.md CLAUDE: Add comprehensive Docker deployment infrastructure 2025-10-16 00:54:56 -05:00
Dockerfile CLAUDE: Add comprehensive Docker deployment infrastructure 2025-10-16 00:54:56 -05:00
exceptions.py CLAUDE: Add comprehensive scorecard submission system 2025-10-16 00:21:32 -05:00
pyrightconfig.json CLAUDE: Convert constants to configurable environment variables 2025-10-16 10:40:22 -05:00
requirements.txt CLAUDE: Add comprehensive Docker deployment infrastructure 2025-10-16 00:54:56 -05:00
VERSION Update VERSION 2026-02-06 02:26:32 +00:00