Skip to content

fix(core): sync credentials across locations - #42412

Closed
jlongster wants to merge 1 commit into
v2from
global-auth-sync
Closed

jlongster wants to merge 1 commit into
v2from
global-auth-sync

Conversation

@jlongster

Copy link
Copy Markdown
Contributor

Summary

  • publish integration credential changes without location metadata so every cached location graph reloads provider state
  • notify locations after automatic OAuth token refreshes as well as login, key update, and removal
  • cover global event delivery across two location-scoped subscribers

Context

Credentials are global, but integration.connection.updated was tagged with the location where authentication occurred. Other cached location graphs therefore retained stale OpenAI routing and could combine a current ChatGPT OAuth token with the public OpenAI Responses endpoint, resulting in 401 errors for missing api.responses.write.

Validation

  • bun typecheck in packages/core
  • bun test test/location-layer.test.ts test/plugin/provider-openai.test.ts test/config/config.test.ts in packages/core
  • Prettier check for changed files

@Enough1122

Copy link
Copy Markdown

Clean fix — the global publish flag is a nice minimal escape hatch: it keeps the location-scoping default intact while letting credential lifecycle events fan out to every location, which is exactly what a shared credential store needs. The routing test (two location contexts, one global publish, both counters increment) covers the mechanism directly.

A few things worth a second look:

  1. Integration.Event.Updated stays location-scoped: connect/update/remove now publish ConnectionUpdated globally but still pair it with a non-global Updated. If remote locations rely on Updated to rebuild integration listings/UI state, they'll learn the credential changed without refreshing whatever Updated drives. Should it be global too, or is ConnectionUpdated genuinely the only signal consumers need?
  2. Refresh now emits events: the refresh path previously published nothing; it now publishes globally on every token refresh. That fixes cross-location staleness, but with several active locations sharing one credential this could get chatty (each refresh wakes subscribers everywhere). Probably fine — just calling out the volume change.
  3. Ordering guarantee: in the attempt paths, global ConnectionUpdated is followed by local Updated. Remote locations see only the first; same-location subscribers see both in order. If any consumer expects the pair atomically, remote behavior will differ subtly.
  4. No payload leaks beyond integrationID, so the widening of visibility looks safe.

Nice work — mainly looking for your take on point 1.

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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.

2 participants