Skip to content

Put the fixes first in the cross-organization missing-key error - #9684

Open
3mdistal wants to merge 4 commits into
mainfrom
alice/cross-org-key-fix-first
Open

3mdistal wants to merge 4 commits into
mainfrom
alice/cross-org-key-fix-first

Conversation

@3mdistal

@3mdistal 3mdistal commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem

When a run can't find a provider key it can read, describeCredentialScopeGap adds an explanation to the "not configured" error. One case it explains: the key is saved in a different organization the person also belongs to. Credentials belong to one organization, so after someone joins a second organization, or their active organization changes, every key saved under the first one looks missing.

That explanation put its fix last, after two sentences about the cause:

A "GITHUB_TOKEN" key is saved in the "Builder.io" organization, but this request resolved to a different organization you also belong to. Credentials are scoped per organization and are not shared between them, so this is an organization mismatch rather than a missing key. Either switch your active organization back to "Builder.io", or save "GITHUB_TOKEN" in the organization this request runs in.

A chat stop shows a one-line headline of at most 240 characters, which keeps the reason's last whole sentence that fits. For this message that was the first sentence, so the headline said the key was elsewhere but never what to do. That happened even for GITHUB_TOKEN and "Builder.io". Builder's review bot flagged it on #9621, which fixed the same problem for the Personal-key message.

When the organization's name can't be read, the message also said "saved in the another organization".

Approach

Same fix as #9621: the fixes come first and the explanation after.

Save "GITHUB_TOKEN" in this organization, or switch your active organization to "Builder.io", where it's saved. Credentials aren't shared between organizations.

The first sentence carries both fixes. The organization's name is the one part with no length limit, so it comes after both of them: when the headline has to cut, a long name is all it can drop.

  • Common key and organization names: the whole explanation fits in the headline.
  • A 35-character key and a 52-character organization name: the cut drops the second sentence and keeps the first.
  • A 125-character organization name: the cut lands inside the name, after both fixes.

When the organization's name can't be read, the message says "switch your active organization to one where it's saved" instead.

An earlier version of this PR named the organization before the second fix. Builder's review bot pointed out that a long name could then push that fix out of the headline; the current order is the answer to that.

What changed

  • packages/core/src/credentials/index.ts: the cross-organization message above. findMemberOrgHoldingCredential now returns { name } (the trimmed name, or null when it can't be read) rather than a pre-quoted string or the word "another", so the message can word each case.
  • packages/core/src/credentials/scope-gap.spec.ts, renamed index.scope-gap.spec.ts: the exact new message, the wording without an organization name, and a name with surrounding spaces. The CI check that mutates changed Core lines runs only specs named after the file they test (index.*.spec.ts for index.ts), so under its old name it never ran these tests, and every mutant on these lines survived. The new name matches index.org-resolution.spec.ts beside it.
  • packages/core/src/agent/production-agent.spec.ts: two more cases in Stop missing-key errors blaming an integration in a person's own chat #9621's stop-headline table. A long key and a long organization name push the cause past the limit, and the headline keeps both fixes. A 125-character organization name is cut inside the name, and the headline still keeps both fixes.
  • A changeset for @agent-native/core.

Safety and operations

  • Only error text changes. The query, which organizations it may look in, and what it reveals (the name of an organization the person already belongs to, never the account, row count or value) are unchanged.
  • Nothing matches on the old wording: no code or docs quote "organization mismatch" or "this request resolved to a different organization". Rollback is a revert.
  • Core's server errors are English-only and have no translation catalog; the old message was too. guard:i18n-changed-copy and guard:i18n-catalogs pass.

Verification

On a Linux test machine, base 21c90bd, head 2ba0fb3:

  • credentials/index.scope-gap.spec.ts, provider-api/index.spec.ts and agent/production-agent.spec.ts: 930 of 930 passed.
  • pnpm mutation:changed: 13 of 14 mutants killed, score 92.86% against a 50% bar. The survivor drops the trim() in the check for an empty name, which changes the message only for an organization named entirely with spaces.
  • Core pnpm typecheck passed. oxlint on the changed files: no errors. Its 8 warnings are existing escapes on lines this PR doesn't touch.
  • oxfmt --check on the changed files passed.
  • guard:no-oracle-loosening passed. The scope-gap test swaps three toContain checks for one exact toBe, and carries the guard's oracle-change: reason saying so.
  • guard:i18n-changed-copy and guard:i18n-catalogs passed.

New and changed tests:

  • The exact new message, the wording when the organization's name can't be read, and a name with surrounding spaces.
  • A stop headline for GOOGLE_APPLICATION_CREDENTIALS_JSON in an organization called "Builder.io Developer Relations and Community Programs" keeps both fixes and drops the cause.
  • A stop headline for a 125-character organization name is cut inside the name and keeps both fixes.

Not checked live: the message in a real chat on beta, which needs the deploy after merge.

Review focus

  • "Switch your active organization" assumes the reader can switch it. That was true of the old message too. Is the other fix, saving the key in this organization, clear enough for someone reading a shared job's stop?
  • Dropping "this is an organization mismatch rather than a missing key". The first sentence now names the organization where the key is saved, which says the same thing.

🤖 Generated with Claude Code

@greptile-apps

greptile-apps Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change reaches missing-key diagnostics across provider API callers and agent stop messages.

The existing localization requirement must be met before merging.

Summary

The PR puts recovery steps first in the cross-organization missing-key error.

  • Missing-key errors now put both fixes before the organization explanation.

Reviews (3) · Last reviewed commit: "Put the organization name after both fix..." · Reviewed by Greptile

Comment thread packages/core/src/credentials/index.ts Resolved
builder-io-integration[bot]

This comment was marked as outdated.

builder-io-integration[bot]

This comment was marked as outdated.

@builder-io-integration builder-io-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Builder reviewed your changes and found 1 potential issue 🟡

Review Details

Incremental Code Review Summary

The latest change moves the organization name after both recovery choices, and the added long-organization-name headline test confirms the previously reported organization-name truncation is fixed. I resolved that earlier thread. The membership-scoped lookup and organization-name disclosure behavior remain unchanged.

I classified this review as high risk because the code concerns credential scope and cross-organization information. One distinct issue remains: credential keys are interpolated before the second recovery choice, and custom-provider registration accepts credential-key strings with no maximum length. A long key can therefore still truncate the headline before the switch-organization fix appears. This is separate from the fixed organization-name case.

🧪 Browser testing: Skipped — browser-test-planner agent is unavailable in this environment.

`them, so this is an organization mismatch rather than a missing key. ` +
`Either switch your active organization back to ${holder}, or save ` +
`"${key}" in the organization this request runs in.`
`Save "${key}" in this organization, or switch your active ` +

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Long credential keys can still hide the second recovery fix

Custom-provider registration accepts credential-key strings without a maximum length, and this interpolates the key before the switch-organization option. A sufficiently long key can push “or switch your active organization…” past the stop-headline limit; please bound/shorten the key in this diagnostic or otherwise keep both fixes visible, and add a long-key headline test.

Fix in Builder

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants