feat(snowflake): session context restoration and OAuth2 error detection improvements - #41440
Draft
betodealmeida wants to merge 7 commits into
Draft
feat(snowflake): session context restoration and OAuth2 error detection improvements#41440betodealmeida wants to merge 7 commits into
betodealmeida wants to merge 7 commits into
Conversation
…o include snowflake
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
betodealmeida
force-pushed
the
snowflake-oauth-followup
branch
from
June 25, 2026 23:38
9fe28aa to
33f9ccd
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #41440 +/- ##
==========================================
- Coverage 64.36% 63.69% -0.68%
==========================================
Files 2653 2655 +2
Lines 144867 145558 +691
Branches 33421 33554 +133
==========================================
- Hits 93250 92706 -544
- Misses 49946 51148 +1202
- Partials 1671 1704 +33
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:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SUMMARY
Follow-up to #36856, closing the remaining gaps between the OSS OAuth2 implementation and production usage at Preset.
Changes:
Session context restoration — overrides
execute()to catch Snowflake error 090105 ("This session does not have a current database"), re-issuesUSE DATABASE / SCHEMA / WAREHOUSE / ROLEstatements, and retries the query. This prevents spurious failures after an OAuth reconnect or connection-pool recycle. If the retry also fails, a user-friendly error is raised instead of a raw engine error. Role is skipped during restore when OAuth is active so the token's role takes precedence.Expanded OAuth2 error detection —
CustomSnowflakeAuthErrorMetanow also matches"User is empty"errors (in addition to"Invalid OAuth access token"), covering the case where Snowflake receives an empty username before the user has completed the OAuth flow.Role stripping during impersonation —
impersonate_user()removes any hardcodedrole=query parameter from the URL when switching toauthenticator=oauth, so the OAuth token's role is used rather than being overridden by the connection-level setting.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION