Skip to content

fix: guard SQLite int(sub) against large OAuth subs (closes #29048) - #29056

Closed
lesbass wants to merge 1 commit into
open-webui:devfrom
lesbass:fix/sqlite-int-overflow-29048
Closed

fix: guard SQLite int(sub) against large OAuth subs (closes #29048)#29056
lesbass wants to merge 1 commit into
open-webui:devfrom
lesbass:fix/sqlite-int-overflow-29048

Conversation

@lesbass

@lesbass lesbass commented Aug 26, 2026

Copy link
Copy Markdown

Description

Google OAuth login fails on SQLite with Python int too large to convert to SQLite INTEGER because Google's 21-digit sub claim exceeds SQLite's signed 64-bit INTEGER range (~9.2e18). The get_user_by_oauth_sub() method unconditionally calls int(sub) for any decimal SQLite sub, causing an OverflowError during SQLAlchemy query binding.

Fix

Added a len(sub) <= 18 guard to the SQLite int(sub) path in backend/open_webui/models/users.py:369. This ensures:

  • Large subs (e.g. Google's 21-digit sub): only the string comparison is used — no int() conversion
  • Small numeric subs (e.g. GitHub user IDs ≤18 digits): still get the int() comparison for type-matching against stored JSON numerics
  • Postgres: completely unaffected (the SQLite-only branch is not entered)

Verification

  • 5 regression tests pass covering: 21-digit Google sub (no int path), 8-digit GitHub sub (int path), 18-digit max-safe sub, 19-digit overflow sub, and non-decimal sub
  • Ruff lint confirms no new lint errors introduced (8 pre-existing errors in the file are unrelated)
  • Single-line diff: 1 file changed, 1 insertion, 1 deletion

Related


Changelog Entry

Fixed

  • Google OAuth login no longer crashes on SQLite when the provider returns a large (21-digit) sub claim

Contributor License Agreement

…i#29048)

Google's 21-digit sub overflows SQLite's signed 64-bit INTEGER when
SQLAlchemy binds int(sub). Add a len(sub) <= 18 guard so the int
comparison path is only used for subs that fit in 64 bits. Small
numeric subs (e.g. GitHub IDs) still get the int path; Postgres is
unaffected.
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.

2 participants