Skip to content

Fix GameData absChallenges model - #248

Merged
Mattsface merged 1 commit into
zero-sum-seattle:mainfrom
gitknr:fix/abs-challenges-model
Jul 31, 2026
Merged

Fix GameData absChallenges model#248
Mattsface merged 1 commit into
zero-sum-seattle:mainfrom
gitknr:fix/abs-challenges-model

Conversation

@gitknr

@gitknr gitknr commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Fix GameData absChallenges validation

## Summary

Fixes `GameData.absChallenges` parsing for MLB API responses where `absChallenges` is returned as an object containing ABS-specific challenge fields.

## Why

Some game feed responses return `gameData.absChallenges` as:

- a single object, not a list
- nested team challenge info using `usedSuccessful`, `usedFailed`, and `remaining`

This caused Pydantic validation errors when calling `get_game()` for affected games.

## What

- Added ABS-specific models for `absChallenges`
- Updated `GameData.abs_challenges` to use the new ABS challenge model
- Updated the `GameData` docstring to reflect the correct field type

## Tests

Verified that `mlb.get_game(822974)` now parses successfully and exposes ABS challenge data through:

- `game.game_data.abs_challenges.away.used_successful`
- `game.game_data.abs_challenges.away.used_failed`
- `game.game_data.abs_challenges.away.remaining`

existing tests were all executed & pass.

Note: I checked `development`, but `Mlb.get_game()` does not exist on that branch. This validation issue occurs in the current `main` implementation of `get_game()`, so this PR targets `main`.

### Risk and impact

Risk level: Minimal

This change is limited to the `GameData.absChallenges` model parsing. It adds a more accurate model for the ABS challenge payload returned by the MLB API and updates `GameData.abs_challenges` to use that model instead of a generic list/dict shape.

The main risk is that if the MLB API returns another unexpected `absChallenges` shape, parsing could still fail for affected games. If something goes wrong, impact should be limited to `get_game()` responses that include `gameData.absChallenges`; unrelated endpoints and non-ABS game data should be unaffected.

@Mattsface

Copy link
Copy Markdown
Member

Looks good. I'll merge this.

@Mattsface
Mattsface merged commit e9793ca into zero-sum-seattle:main Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants