Skip to content

API boxscore: empty per-athlete stats array in ESPN summary crashes boxscore (IndexError) #92

Closed

Description

@dcstats

Symptom

get_game_boxscore(..., source="api") returns an empty DataFrame for some games, logging:

ERROR: 401604889 - Boxscore (API): list index out of range
ERROR: 401592369 - Boxscore (API): list index out of range

Root cause (upstream)

ESPN's summary endpoint (site.api.espn.com/.../summary?event={id}) sometimes lists an athlete in boxscore.players[].statistics[0].athletes with didNotPlay: false but an empty stats array, while the team's names labels list has 13 entries:

  • 401604889 (Point Park at Robert Morris): M. Murphy, a starter, stats: [] — played 2 min with a fully zero stat line
  • 401592369 (Southern Indiana at Michigan State): Javius Moore, bench, stats: [] — played 5 min with 1 FGA (a 3PA) and 1 TO

_boxscore_adapter (espn_api.py) passes the empty list through, and _build_player_rows (cbbpy_utils.py) indexes players[j]["stats"][i] per label → IndexError → the entire game's boxscore comes back empty.

The data exists elsewhere

This is purely a summary-endpoint gap, not missing data:

  • HTML embed (source="html") carries full rows for both players (Murphy: 2 min all zeros; Moore's line present) and scrapes these games fine.
  • ESPN core API has the complete line: sports.core.api.espn.com/v2/.../events/401592369/competitions/401592369/competitors/88/roster/5177372/statistics/0 returns minutes 5, FGA 1, 3PA 1, TO 1 for Moore.
  • The summary's own plays array contains Moore's individual events (missed 3PT jumper at 5:03 Q1, turnover at 3:47 Q1), so PBP-side data is unaffected.

Fix direction

Keep the row rather than dropping the athlete like a DNP (dropping would lose a real starter and break API/HTML row-count parity). Options:

  1. Pad short/empty stats in _boxscore_adapter (blanks/zeros) — cheap, but Moore's real stats would read as zero where HTML has them.
  2. Backfill the missing line from the core API roster/statistics endpoint (one extra request only when an empty stats array is encountered).

Either way the IndexError should not take down the whole game's boxscore.

Activity

  1. added
    bugSomething is incorrect or broken
    upstreamCaused by ESPN data/API behavior, not cbbpy code
    on Jul 24, 2026
  2. self-assigned this
    on Jul 24, 2026
  3. added this to the v2.2.0 milestone on Jul 24, 2026
  4. dcstats commented on Jul 24, 2026

    @dcstats
    OwnerAuthor

    Update: the empty stats arrays are transient, not persistent.

    • ~1h after the failing run, cbbpy box 401592369 --stdout returned a complete boxscore (Moore's line included). cbbpy box 401604889 --stdout failed once ("skipping blank boxscore" + IndexError in the log), then succeeded on immediate retry.
    • Direct re-fetches of both summary endpoints (3x each) now show zero empty-stats athletes, whereas fetches ~1h earlier reproduced the gap on both games.

    Both games finished long ago, so the underlying core data isn't changing — the site API was serving a stale/bad cached aggregation (empty stat-line join) and has since served a good generation. Different requests can hit different cache copies, which explains fail-then-succeed on back-to-back runs.

    Implication for the fix: an empty stats array on a non-DNP athlete is a signal of a bad cached summary. Reasonable strategies:

    1. Treat it as retryable — re-request the summary (bounded), since a fresh/other cache copy usually has the data.
    2. Core-API backfill per affected athlete (deterministic, 1 request each) as originally proposed — works even if every retry hits the bad copy.

    Either way, still never let one bad athlete entry blank the whole game's boxscore.

  5. added a commit that references this issue on Jul 24, 2026
  6. dcstats commented on Jul 29, 2026

    @dcstats
    OwnerAuthor

    fixed with 6277b88

  7. linked a pull request that will close this issue2.2.0 #94on Jul 29, 2026
  8. removed a link to a pull request2.2.0 #94on Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething is incorrect or brokenpriority: lowNice to haveupstreamCaused by ESPN data/API behavior, not cbbpy code

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions