Skip to content

feat(snowflake): session context restoration and OAuth2 error detection improvements - #41440

Draft
betodealmeida wants to merge 7 commits into
masterfrom
snowflake-oauth-followup
Draft

feat(snowflake): session context restoration and OAuth2 error detection improvements#41440
betodealmeida wants to merge 7 commits into
masterfrom
snowflake-oauth-followup

Conversation

@betodealmeida

@betodealmeida betodealmeida commented Jun 25, 2026

Copy link
Copy Markdown
Member

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-issues USE DATABASE / SCHEMA / WAREHOUSE / ROLE statements, 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 detectionCustomSnowflakeAuthErrorMeta now 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 impersonationimpersonate_user() removes any hardcoded role= query parameter from the URL when switching to authenticator=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

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@netlify

netlify Bot commented Jun 25, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 9fe28aa
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a3dba4b41194600084b1cd2
😎 Deploy Preview https://deploy-preview-41440--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@betodealmeida betodealmeida changed the title Snowflake oauth followup feat(snowflake): session context restoration and OAuth2 error detection improvements Jun 25, 2026
@betodealmeida
betodealmeida force-pushed the snowflake-oauth-followup branch from 9fe28aa to 33f9ccd Compare June 25, 2026 23:38
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 32.65306% with 66 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.69%. Comparing base (defacc3) to head (33f9ccd).
⚠️ Report is 855 commits behind head on master.

Files with missing lines Patch % Lines
superset/db_engine_specs/snowflake.py 32.65% 66 Missing ⚠️
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     
Flag Coverage Δ
hive 39.21% <32.65%> (-0.13%) ⬇️
javascript 68.56% <ø> (ø)
mysql 57.90% <32.65%> (-0.16%) ⬇️
postgres 57.96% <32.65%> (-0.17%) ⬇️
presto 40.79% <32.65%> (-0.14%) ⬇️
python 58.17% <32.65%> (-1.40%) ⬇️
sqlite 57.62% <32.65%> (-0.16%) ⬇️
unit ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants