fix(core): register only credential-shaped env names for integrations - #44066
fix(core): register only credential-shaped env names for integrations#44066chandlerm923 wants to merge 1 commit into
Conversation
models.dev lists provider env vars in setup order, so non-secret values (account id, host, base url) that precede the actual key get registered as the env auth method and can win connection resolution's first-set-wins pick. Filter registered names to *_API_KEY/*_TOKEN/*_PAT when any match, falling back to the full list otherwise. Fixes anomalyco#44065
— automated review (ox-alpha, round2) |
Issue for this PR
Closes #44065
Type of change
What does this PR do?
ModelsDevPlugin(packages/core/src/plugin/models-dev.ts) registers every env varname models.dev lists for a provider, verbatim, as one
envauth method. Connectionresolution takes the first set var as the credential. For providers where models.dev
lists a non-secret setup value before the key —
cloudflare-workers-ai(
CLOUDFLARE_ACCOUNT_ID→CLOUDFLARE_API_KEY),snowflake-cortex,databricks,neon— the non-key value wins and gets sent as the bearer token, so a standard setupgets a deterministic 401.
#43077 hit the same bug for
google-vertexand fixed it by hardcoding a per-providerenvironmentNames()filter on thev2branch (azure + google-vertex only). This PRgeneralizes that instead of adding more per-provider cases:
credentialEnvNames()keeps only names ending in
_API_KEY/_TOKEN/_PATwhen any of the provider's envnames match that shape, and falls back to the full list otherwise (so providers with
unfamiliar naming still register their env var same as before).
How did you verify your code works?
cloudyfixture provider (CLOUDY_ACCOUNT_ID,CLOUDY_API_KEY) topackages/core/test/plugin/fixtures/models-dev.jsonand asserted only the_API_KEYname gets registered (packages/core/test/plugin/models-dev.test.ts)bun test test/plugin/models-dev.test.ts— 2 passbun run typecheckinpackages/core— cleanbun test(fullpackages/coresuite) has 2 pre-existing failures insnapshot.test.tsunrelated to this change — reproduced identically with thisdiff stashed out, so confirmed pre-existing (git/hg sandbox issue in this
environment, not caused by this PR)
Screenshots / recordings
Not a UI change.
Checklist