Auth extension: set snowflake partner tag in setting#13737
Conversation
|
E2E Tests 🚀 |
PETE's assessment 🧪Verdict: Adequate -- The PR adds 183 lines of extension-host Mocha tests that cover every new exported function and every significant branch of the seeding logic. What changed
Tests in this PR
Existing coverageNew functions; no pre-existing tests to verify. Suggested additionsNone. PETE (Positron Extreme Test Experiment) - LLM-based test-coverage advisor, in pilot. Triggers on PR open and on |
|
timtmok
left a comment
There was a problem hiding this comment.
Should the default value for authentication.snowflake.customHeaders be posit_positron? Otherwise, resetting the preference makes the value blank.
I also couldn't get the preference set by setting SF_PARTNER. The environment variable gets overridden with posit_positron. I thought the setting the environment variable would take precedence?
Two fixes from #13737 review: - Set the schema default of authentication.snowflake.customHeaders to { "User-Agent": "posit_positron" } so "Reset Setting" produces a valid tag instead of blanking the value. - Re-seed the User-Agent header on activation when SF_PARTNER changes. The previous logic skipped any time User-Agent was already set, so once the default had been written, a later SF_PARTNER env override was silently ignored. Now the function tracks its last seeded value in globalState and overwrites only values it wrote itself, leaving user customizations untouched. Tests cover: schema-default in effect, env override of the default, env change overrides our prior seed, scope merging, and the user- customization guard.
ca193b6 to
e18b550
Compare
|
/recheck-tests |
ah thank you! I had opted out of setting the default value for Also fixed up the env var precedence issue and added tests to cover these cases. |
|
I find that I can't set Did this ever work to set the value by environment variable through the process? Or do we always have to set it with the preference? |
|
I moved #13731 forward to 2026.07. I feel like writing to customHeaders is maybe not a great direction to go in, because we have to deal with all this precedence complexity and I wonder if we may want to skew towards the old approach in Positron Assistant. This precedence complexity doesn't seem like it should be the responsibility of the Auth extension. I'm not sure if we'd go with the approach in https://github.com/posit-dev/assistant/pull/1445 exactly, but maybe we lean towards that instead. Putting this in draft in the meantime! |
Fixes #13731
Summary
Moves Snowflake partner-tag resolution into the authentication extension so Posit Assistant (and any future consumer) reads the
User-Agentfromauthentication.snowflake.customHeadersinstead of re-implementing the lookup. This gives us one source of truth for the value and letsauthentication.snowflake.customHeaders(added in #13664) actually carry the partner tag by default.On activation, the Snowflake auth provider seeds
customHeaders["User-Agent"]with the resolved partner tag. Resolution precedence isenvironmentVariables.set.SF_PARTNER, thenprocess.env.SF_PARTNER, then the defaultposit_positron. The schema default forcustomHeadersis{ "User-Agent": "posit_positron" }, so "Reset Setting" gives you a valid tag instead of blanking the value.Two guardrails:
User-Agentit wrote (inglobalState) and only overwrites values it wrote itself. If you've customisedUser-AgentincustomHeaders, your value stays. The setting is the escape hatch for enterprise gateways and we don't clobber it.customHeadersis defined (workspace folder, then workspace, then global), since object settings don't merge across scopes.Seeding runs on each activation, so changing
SF_PARTNERand relaunching picks up the new tag automatically. No need to editcustomHeadersby hand.The duplicate resolution in
positron-assistant'ssnowflakeProvider.tscan be removed in the Positron Assistant deprecation.Validation Steps
@:posit-assistant
This is a config-seeding change with no direct UI. Validate manually:
authentication.snowflake.customHeaderssetting and reload the window.authentication.snowflake.customHeaders. Confirm it contains"User-Agent": "posit_positron".SF_PARTNER=test-user-agentset in the environment, and confirm the value now reflectstest-user-agent.SF_PARTNERset. Confirm the value reverts toposit_positron(the extension overwrites its own prior seed).User-Agentto a custom value inauthentication.snowflake.customHeaders, reload, and confirm the value is preserved (not overwritten).I was able to confirm this works by adding debug logging locally, and confirming that the user agent header was included with the snowflake request. There is not currently a way to see the headers directly from Posit Assistant.
SNOWFLAKE_ACCOUNTinauthentication.snowflake.credentials