Skip to content

fix(runners): don't crash the runtime API on "Lutris/x.y.z" user agents - #771

Merged
strycore merged 1 commit into
masterfrom
fix/runtime-api-user-agent
Oct 9, 2026
Merged

strycore merged 1 commit into
masterfrom
fix/runtime-api-user-agent

Conversation

@strycore

@strycore strycore commented Oct 9, 2026

Copy link
Copy Markdown
Member

Production error reports on 2026-09-27 and 2026-09-30: IndexError: list index out of range at runners/views.py in RuntimeVersions.get, on GET /api/runtimes/versions.

Both requests used the user agent Lutris/0.5.22. The client itself sends Lutris 0.5.22, but anything starting with Lutris without a space crashed on user_agent.split()[1]. RuntimeListView.get_queryset had the same line.

This PR adds a single helper, get_client_version_number(user_agent), which both views now use:

  • returns 0 for non-Lutris user agents (no change)
  • accepts Lutris 0.5.22 and Lutris/0.5.22
  • raises ClientTooOld (426) instead of a 500 when no valid version can be read, e.g. a bare Lutris

The < 0.5.11 minimum check in RuntimeListView behaves the same.

Tests: new TestClientVersion cases cover both separators, non-Lutris agents, a bare Lutris, and an end-to-end call to /api/runtimes/versions with Lutris/0.5.22. The end-to-end call raises IndexError without the fix. The full suite passes (171 tests), as do ruff check and ruff format --check.

🤖 Generated with Claude Code

RuntimeVersions and RuntimeListView took the client version from
user_agent.split()[1], which raised IndexError (a 500 on
/api/runtimes/versions) for any user agent starting with "Lutris" but
without a space, such as "Lutris/0.5.22". Parse the version in one
helper that accepts both separators and answers ClientTooOld when no
version can be read.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@strycore
strycore merged commit 635dbc1 into master Oct 9, 2026
4 checks passed
@strycore
strycore deleted the fix/runtime-api-user-agent branch October 9, 2026 06:36
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.

1 participant