• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / supabase-py / 41634839651 / 13
98%
main: 98%

Build:
DEFAULT BRANCH: main
Ran 03 Nov 2026 12:23PM UTC
Files 59
Run time 1s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

03 Nov 2026 12:20PM UTC coverage: 94.452% (+0.005%) from 94.447%
41634839651.13

push

github

web-flow
fix(auth): raise AuthInvalidJwtError for malformed tokens in set_session (#1920)

Fixes SDK-2669.

## Problem

`set_session()` guarded the decode with `access_token.split(".")[1]`, so
an access token without a `.` (opaque or malformed) raised a bare
`IndexError` before `decode_jwt` could raise `AuthInvalidJwtError`.
Callers catching `AuthError` missed it.

`decode_jwt` also leaked a bare `ValueError` for segments with non-ASCII
characters, because `urlsafe_b64decode` raises `ValueError` rather than
`binascii.Error` for those. That affected every `decode_jwt` caller,
including `get_claims` and `_get_authenticator_assurance_level`.

## Changes

- `set_session` decodes any non-empty access token directly, matching
supabase-js `_setSession`, which calls `decodeJWT` unconditionally.
`decode_jwt` already validates the segment count, base64 and JSON shape.
- `decode_jwt` catches `ValueError` (the common base of
`binascii.Error`, pydantic's `ValidationError` and the non-ASCII error)
and raises `AuthInvalidJwtError`.
- Behaviour change: a token with an empty payload segment (for example
`"header..signature"` or `"abc."`) used to skip decoding and was
silently refreshed with the refresh token. It now raises
`AuthInvalidJwtError`, matching supabase-js.
- Otherwise behaviour is unchanged: an expired token is refreshed, an
empty access token with no refresh token raises
`AuthSessionMissingError`, and a valid token notifies `SIGNED_IN`.

## Tests

- `test_set_session.py` (async and generated sync): non-JWT, two and
four segments, undecodable base64 and non-ASCII tokens all raise
`AuthInvalidJwtError` without any HTTP request. Also covers the empty
token `AuthSessionMissingError` path.
- `test_set_session.py` also covers the trailing dot and empty payload
cases above.
- `test_get_claims.py` (async and generated sync): opaque, undecodable
base64 and non-ASCII tokens raise `AuthInvalidJwtError`.
- `test_helpers.py`: undecodable base64 and non-ASCII cases for
`decode_jwt`.

4869 of 5155 relevant lines covered (94.45%)

0.94 hits per line

Source Files on job run-ubuntu-latest-3.15-auth - 41634839651.13
  • Tree
  • List 59
  • Changed 6
  • Source Changed 0
  • Coverage Changed 6
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 41634839651
  • 301ce7db on github
  • Prev Job for on main (#41634432636.14)
  • Next Job for on main (#41635363760.12)
  • Delete
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc