-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
Pydantic validation fails for game data API requests using gamepks.
Package Version: 0.7.1
Python Version: 3.10.16
code to reproduce:
mlb.get_game(game_id=gamepk).game_datawhere gamepk is the integer provided in the log.
There are 6,002 gamepks in the log file. Most are due to the base variable in playEvents expecting type str when the API passes int instead (4,743 errors thrown). Another common error is the API attempting to pass dict instead of str for variables like umpire and linescore.offense.<position> (1,537 errors thrown).
Example:
Traceback (most recent call last):
File "/src/back_propagation.py", line 171, in _fill_game_data
game = mlb.get_game(game_id=gamepk).game_data
File "/home/user/.local/lib/python3.10/site-packages/mlbstatsapi/mlb_api.py", line 907, in get_game
return Game(**mlb_data.data)
File "/home/user/.local/lib/python3.10/site-packages/pydantic/main.py", line 250, in __init__
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for Game
liveData.plays.allPlays.70.playEvents.0.base
Input should be a valid string [type=string_type, input_value=1, input_type=int]
For further information visit https://errors.pydantic.dev/2.12/v/string_type
gamepk: 776160Full log:
mlb_api_pydantic_validation_errors.log
Metadata
Metadata
Assignees
Labels
No labels