diff --git a/src/base_classes/baseball.py b/src/base_classes/baseball.py index 83b90a24..ac84bfb7 100644 --- a/src/base_classes/baseball.py +++ b/src/base_classes/baseball.py @@ -151,7 +151,12 @@ class Baseball(SportsCore): # Only log detailed information for favorite teams if is_favorite_game: - self.logger.debug(f"Full status data: {game_event['status']}") + # Use the validated competition-level `status` here too. MiLB + # events carry no event-level one, so this debug line raised a + # KeyError and dropped the very games it was meant to help + # diagnose -- and only for favourites, which is the worst way + # for it to fail. + self.logger.debug(f"Full status data: {status}") self.logger.debug(f"Status type: {game_status}, State: {status_state}") self.logger.debug(f"Status detail: {status['type'].get('detail', '')}") self.logger.debug( diff --git a/test/test_sports_base_characterization.py b/test/test_sports_base_characterization.py index 980446f7..42c7f427 100644 --- a/test/test_sports_base_characterization.py +++ b/test/test_sports_base_characterization.py @@ -363,6 +363,20 @@ class TestExtractGameDetailsContract: assert details is not None assert details["inning"] == 7 + def test_baseball_live_without_top_level_status_extracts_for_favorites(self): + # The favourite-team branch logs the status payload for diagnostics and + # read the same event top-level key the test above proves can be + # absent. So the identical MiLB event that extracts fine for a + # non-favourite raised KeyError and was dropped once the team WAS a + # favourite -- the worst shape for the bug, since it only hit the games + # the user cared most about, and only on the diagnostic path that was + # supposed to help debug them. + event = make_event("413", "in", "2026-07-16T23:05:00Z", period=7) + del event["status"] + details = extract(Baseball, event, favorites=["TB"]) + assert details is not None + assert details["inning"] == 7 + # --------------------------------------------------------------------------- # 2. update() flow on concrete subclasses (offline, cache-fed)