feat(core): Snowflake Cortex OAuth login for V2 - #41111
Conversation
Port account-scoped PKCE OAuth from the V1 plugin into the V2 snowflake-cortex provider: browser login with account/role prompts, refresh via credential metadata, and request-time Cortex baseURL resolution from OAuth accountId/baseURL so native openai-compatible routes hit the correct host with a bearer access token.
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
anujbolewar
left a comment
There was a problem hiding this comment.
looks reasonable for a local oauth flow — pkce + a callback server bound to 127.0.0.1 is the standard safe pattern. one q: if the user misses the 5min window, do they just get an error or can they restart the flow cleanly?
|
Good question. On the 5-minute window they get a hard error from the OAuth callback: There is no mid-flow resume after that timeout: the failed attempt is discarded. Starting Login with Snowflake again runs a fresh |
Issue for this PR
Closes #34780
Type of change
What does this PR do?
V2 already has Snowflake Cortex as a catalog provider with PAT/env auth, but it never registered the browser OAuth login that V1 had. Without that, users cannot connect via Snowflake's external-browser OAuth, and the account-scoped Cortex host never ends up on the request.
This ports the V1 flow into the V2
snowflake-cortexplugin:https://{account}.snowflakecomputing.comcredential.metadata.accountId{ accountId, baseURL }on the OAuth credentialIt also teaches
fromCatalogModelto apply OAuth routing metadata: for Snowflake, derive the Cortex OpenAI-compatible base URL fromaccountId(or use an explicitmetadata.baseURL). Key credentials still project metadata into the request body; OAuth metadata is not dumped into the body.Why this works: Snowflake OAuth is account-hosted, so refresh and API calls need the same account id that login captured. Putting that on credential metadata and resolving
api.urlat request time matches how V1 stashedaccountIdand built the host in the loader, without reintroducing a V1-style fetch monkey-patch for the native path.How did you verify your code works?
bun test test/plugin/provider-snowflake-cortex.test.ts test/session-runner-model.test.ts(33 pass): method registration, account/role helpers,cortexFetchquirks, OAuth baseURL + bearer resolutionScreenshots / recordings
N/A (no UI change)
Checklist