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

supabase / supabase-py / 41662624502 / 21
98%
main: 98%

Build:
DEFAULT BRANCH: main
Ran 03 Nov 2026 03:22PM UTC
Files 43
Run time 4s
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 03:19PM UTC coverage: 98.498%. Remained the same
41662624502.21

push

github

web-flow
fix(auth): keep expired session in initialize_from_storage when auto refresh is off (#1938)

## What

`initialize_from_storage()` deleted a stored session whose access token
had expired (or was within `EXPIRY_MARGIN`) when
`auto_refresh_token=False`, even though the refresh token was still
valid. Apps restarting with auto refresh off after the access token
expired were signed out.

This changes `_recover_and_refresh` to match auth-js
`_recoverAndRefresh`:

- Auto refresh off: the expiring session stays in storage, so
`get_session()` refreshes it on demand.
- Auto refresh on: the session is refreshed. Previously a successful
refresh also fell through to `_remove_session()`, which deleted the
freshly refreshed session. It now returns after the refresh.
- A failed refresh still removes the session, and retryable errors still
schedule a retry.
- A stored session without a refresh token is still removed, since it
cannot be recovered.

`_sync/` is regenerated from `_async/`.

## Tests

New unit tests in `tests/_async/test_initialize_from_storage.py` (and
the generated sync version) use an HTTPX `MockTransport` token endpoint
and cover:

- auto refresh off with an expired session, and with a session inside
the expiry margin
- auto refresh on with a successful refresh
- auto refresh on with a failed refresh
- auto refresh on with a retryable error (session kept, retry runs and
refreshes)
- auto refresh on with retryable errors until `MAX_RETRIES` (session
removed)
- an expired session without a refresh token
- `get_session()` raising when the refresh of a kept session is rejected

Fixes #1911

SDK-2649


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Bug Fixes**
* Stored authentication sessions are now preserved during initialization
when automatic token refresh is disabled and a refresh token is
available. The session can be refreshed later when retrieved.
  * Expi... (continued)

2952 of 2997 relevant lines covered (98.5%)

0.98 hits per line

Source Files on job run-ubuntu-latest-3.15-storage - 41662624502.21
  • Tree
  • List 43
  • Changed 0
  • Source Changed 0
  • Coverage Changed 0
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Build 41662624502
  • 14368323 on github
  • Prev Job for on main (#41648463269.25)
  • Next Job for on main (#41662786735.7)
  • 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