ggtracker / ggtracker/sc2reader

Error getting race letter for race-less player

Open Beginner friendly
#232 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
169
Forks
152
PR merge metrics
No merged PRs in 30d

Description

I got a report from a player about my map's replays breaking their script. When I tested it with a replay of my own, I got the following error:


--------------------------------------
/home/alzarath/Documents/StarCraft II/Accounts/#######/#-S#-#-######/Replays/Multiplayer/Impossible Cyrus (87).SC2Replay

   Map:      Impossible Cyrus
   Date:     2025-11-22 18:28:13+00:00
Error with '/home/alzarath/Documents/StarCraft II/Accounts/#######/#-S#-#-######/Replays/Multiplayer/Impossible Cyrus (87).SC2Replay': 
string index out of range
Traceback (most recent call last):
  File "/home/alzarath/.local/lib/python3.14/site-packages/sc2reader/scripts/sc2printer.py", line 175, in <module>
    main()
    ~~~~^^
  File "/home/alzarath/.local/lib/python3.14/site-packages/sc2reader/scripts/sc2printer.py", line 168, in main
    printReplay(filepath, arguments)
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "/home/alzarath/.local/lib/python3.14/site-packages/sc2reader/scripts/sc2printer.py", line 23, in printReplay
    lineups = [team.lineup for team in replay.teams]
               ^^^^^^^^^^^
  File "/home/alzarath/.local/lib/python3.14/site-packages/sc2reader/objects.py", line 48, in lineup
    return "".join(sorted(p.play_race[0].upper() for p in self.players))
                   ~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/alzarath/.local/lib/python3.14/site-packages/sc2reader/objects.py", line 48, in <genexpr>
    return "".join(sorted(p.play_race[0].upper() for p in self.players))
                          ~~~~~~~~~~~^^^
IndexError: string index out of range

My CPU player, the seventh player, Player 14, is considered "Neutral" for its race (set in the Player Properties). The script appears to read this as an empty string, so there's no first letter to return.

Here's the replay in question. Impossible Cyrus (87).SC2Replay.zip

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in sc2reader/objects.py at Team.lineup, specifically the play_race indexing shown in the traceback. Reproduce the failure with the attached Impossible Cyrus (87).SC2Replay and inspect how the neutral CPU player is represented. Done means sc2printer.py can process that replay without an IndexError while preserving lineup generation for players with races.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
game-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.