Repository navigation
fix(snowflake): refresh rejected OAuth tokens - #43623
aminghadersohi merged 6 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #43623 +/- ##
==========================================
+ Coverage 79.21% 79.22% +0.01%
==========================================
Files 2879 2880 +1
Lines 165922 166248 +326
Branches 38377 38425 +48
==========================================
+ Hits 131427 131717 +290
- Misses 32018 32041 +23
- Partials 2477 2490 +13
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
The flagged issue is correct. In forced-refresh mode, the To resolve this, you should commit the deletion within the # Inside the forced-refresh block in superset/utils/oauth2.py
# After the deletion logic:
token_session.delete(token)
token_session.commit() # Ensure the deletion is persistedI have checked the available PR context, and there are no other comments to address. Would you like me to perform any further analysis? superset/utils/oauth2.py |
|
Addressed the open OAuth review feedback in 035cdd3:
Verification: the previously failing GSheets test passes, 189 related unit tests pass, and pre-commit passes for all changed files. |
Code Review Agent Run #70b496Actionable Suggestions - 0Additional Suggestions - 4
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
|
Heya, one more thing before this can merge, though I want to flag upfront I haven't proven this against the real code, just traced it and confirmed the underlying SQLAlchemy behavior with an isolated repro, so take this as a question to verify rather than a confirmed bug.
Could we add a test that uses two genuinely separate sessions (not |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Code Review Agent Run #8b1a2cActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
SUMMARY
Snowflake can reject an otherwise unexpired OAuth2 access token after a Snowflake-side role or grant change. Superset previously treated this as an interactive reauthorization condition, leaving the cached access token in place rather than attempting the stored refresh token.
This change recognizes Snowflake's documented
390303OAuth access-token error, forces a refresh-token exchange even when the cached access token has not expired, and retries synchronous and asynchronous SQL execution once. A retry context prevents the existing interactive OAuth handler from intercepting the first failure. If silent refresh is unavailable or rejected, the existing interactive authorization flow remains the fallback.Retries are restricted to engine-classified OAuth errors and are skipped after a multi-statement query has made progress. Attempt, success, and failure counters plus a structured log record provide visibility into forced refreshes.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Not applicable; this is a backend-only change.
TESTING INSTRUCTIONS
Run:
PYTHONPATH="$PWD/superset-core/src" pytest -q \ tests/unit_tests/utils/oauth2_tests.py \ tests/unit_tests/db_engine_specs/test_snowflake.pyThe 151 focused tests verify that:
390303and the existing exact error message are classified as OAuth failures.invalid_grantresponses delete stored tokens; transient and ambiguous provider failures preserve them.Pre-commit was also run against every changed file.
ADDITIONAL INFORMATION
Blast radius
This affects database OAuth2 query execution paths only. Forced refresh is reached only when an engine's
needs_oauth2()classifier matches; Snowflake's matcher is limited to its DBAPI exception type plus error code390303or the existing exact invalid-token message. There are no schema, permissions, RLS, or UI changes.Risk & rollback
The primary risk is retrying a query after a misclassified error. The Snowflake match is deliberately narrow, and multi-statement executions are not retried after progress is recorded. Rollback is a normal revert of this commit; there are no migrations or persisted-format changes.
Review guidance
Please review
superset/utils/oauth2.pyfirst, especially the retry context and forced-refresh fallback behavior, followed by the two SQL execution call sites. The Snowflake matcher change is intentionally limited to the provider's documented access-token-invalid code.