GeezerVison is showing github.com — fix(core): drop a well-known source when its last credential is removed by 2SinceJuly · Pull Request #59528 · anomalyco/opencode
Conversation
2SinceJuly
commented
Oct 27, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Issue for this PR
Closes #59320
Type of change
What does this PR do?
opencode auth logout deletes the credential but leaves the .well-known/opencode source registered. Without a credential, Config.loadWellknownEntry cannot resolve the manifest, so it falls back to WellKnown.cached(origin) and keeps applying the last remote config (models, policies). That is why logout looked incomplete.
Credential.remove in core now drops a well-known source when the removed credential was the integration's last one, so every core caller gets the same invariant instead of only the server.credential HTTP handler doing it. WellKnown.remove already existed and publishes WellKnown.Event.Updated, which the existing subscribers use to reload config and integrations. Other integrations, and well-known integrations that still have a credential, keep the previous path. No protocol or config schema changes.
Sources that were already orphaned before this fix are intentionally not pruned: a registered source without a credential is also the normal state between integration.wellknown.add and the first login, so earlier orphans are indistinguishable from a source the user just added and has not logged into yet. Cleaning those needs a one-time migration keyed on state we do not record today.
How did you verify your code works?
New HTTP-level regression test in packages/server/test/credential.test.ts:
- Register a well-known manifest with
config.model = embedded/model.
- Create two credentials for it;
/api/config exposes that model.
- Remove one credential: the integration and the model stay.
- Remove the last credential: the integration disappears and
/api/config no longer contains the model.
New core-level test in packages/core/test/credential.test.ts mocks WellKnown and asserts that Credential.remove, called directly without the HTTP layer, removes the source only when the last credential goes. With the rule implemented in the handler only, that core test fails.
Also ran bun run check at the repository root plus the core credential / wellknown / integration / config suites and the server credential suite, and prettier --check on the changed files.
Visual
No visual change; this only affects CLI auth and config behavior.
Screenshots / recordings
Not a UI change.
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR
Added by the opencode bot (AI-generated).
Related: #54645
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…oved
Logging out removed the credential but kept the well-known source, so the
config loader fell back to its last cached remote config and kept applying
it. Remove the source with its last credential; the existing
WellKnown.Event.Updated subscribers reload config and integrations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix works. I ran the new test on the base and with this PR. On the base, removing the last credential leaves the well-known integration and its cached embedded/model config in place. With the PR both are gone, and removing one of two credentials keeps them. tsc -b for packages/server and the nearby server/core auth, config, policy, well-known and credential tests pass. I couldn't run the CLI end to end in this sandbox.
Public API: no endpoint, schema or flag changes. One behaviour change: DELETE /api/credential/:id on the last credential of a well-known integration now also unregisters the source (the integration disappears and its cached config is cleared). To log back in, users need auth login <url> again rather than the integration name. The app's provider "disconnect" (which removes all credentials) now forgets the source too.
Concerns:
- Layer: the cleanup only happens in the HTTP handler. Today every credential removal goes through it, but the rule "no credential left → drop the well-known source" would sit better next to
Credential.remove or as a core subscriber, so a future core caller doesn't skip it. Not blocking.
- Existing users: anyone who already logged out before this fix still has an orphaned source with cached config, and this change doesn't clean that up. Worth a note or a one-time cleanup.
- Test: it's fairly long for what it checks, and
eventually polls with sleeps. It's acceptable, but it could be trimmed to the add / two credentials / remove one / remove last flow with fewer helpers.
Open PR #54687 handles an overlapping symptom in Config (a logged-out endpoint contributes no documents) and keeps the source, so maintainers will likely want to pick one approach.
Related: #54645
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only new commit merges dev into the branch. The PR's own changes haven't changed, and the regression test still passes on the new head. The public API is unchanged apart from the behaviour change noted in the earlier review: removing the last credential also unregisters the well-known source. The earlier point about moving the cleanup into core is still open.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only new commit merges dev into the branch. The PR's own changes haven't changed, and the regression test still passes on the new head. The public API is unchanged apart from the behaviour change noted earlier: removing the last credential also unregisters the well-known source. The earlier point about moving the cleanup into core is still open.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Move the cleanup out of the HTTP handler so every core caller that removes
the last credential also drops the source and its cached remote config.
2SinceJuly
changed the title
fix(server): drop a well-known source when its last credential is removed
fix(core): drop a well-known source when its last credential is removed
Oct 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The earlier point is addressed: the rule now lives in core Credential.remove, so every caller gets it. Not pruning sources that were already orphaned makes sense, since a source with no credential is also the normal state right after wellknown.add. I re-ran the HTTP regression test (it fails on the base and passes here), the new core test, the nearby core and server suites, and tsc -b for core and server. All pass.
The public API is unchanged. One behaviour change: removing the last credential of a well-known integration now also unregisters its source, so logging back in needs auth login <url>.
One small gap, noted inline: the cleanup checks the in-memory snapshot(), so it can miss a source if config hasn't loaded the sources yet.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…source
The loaded cache is only filled once the sources load, so a removal that ran
before config did skipped the cleanup. Credential.remove now asks
WellKnown.has, which reads the stored list, and the core test keeps the
cache empty to pin that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed: the cleanup now checks the saved source list (WellKnown.has) instead of the in-memory cache, so it also works before config has loaded the sources. I re-ran the core credential, well-known, integration and config suites, the server credential test, and tsc -b for core and server. All pass.
has is a new method on the internal core WellKnown service, not part of the public API. Nothing new to raise.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Parking this for now: the repo caps open pull requests from contributors without write access at 3, and I need a slot for a fix for a newer reproduced issue. Nothing is wrong with the change, and I'll reopen it as soon as one of my other PRs lands or a slot frees up.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Reopened — thanks for flagging. Removing the last credential now also unregisters the well-known source (and drops its cached embedded/model config), so auth logout no longer leaves a stale integration behind.
Verified on the current head: core credential / wellknown / config suites, the server credential regression test (fails on base, passes here), and tsc -b for core + server.
@rekram1-node @thdxr could you take a look when you have a slot? A user reports auth logout is broken on dev.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Merged current dev (403 commits behind, plain merge — no rebase, no force-push) to clear the conflict. New head: 57da7a7b5.
Conflict was in packages/core/src/credential.ts: kept the PR's local list helper because Credential.remove() calls it, while dev inlined the same body into the service. Both forms are identical.
Verified on the new head:
- core:
credential, wellknown, config, integration, integration-refresh — 81 tests pass
- server:
test/credential.test.ts regression test passes (removing the last credential removes its well-known source)
bun run check passes (oxlint + ast-grep + sdk-docs + turbo typecheck across all 35 packages)
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Keep both sides of the credential layer: upstream's shared `rows()` helper
and transaction helpers alongside this branch's `list` binding, which
`Credential.remove` reuses to check whether the integration still has a
credential before dropping its well-known source.
The diagnostic test keeps upstream's `withTempDir` body and only adds the
`has` member to its WellKnown mocks, which the interface now requires.
|
Rebased onto today's dev so the branch merges again — it had gone CONFLICTING against packages/core/src/credential.ts (upstream now shares a rows() query helper there) and the diagnostic test (upstream moved it to withTempDir). Both sides are kept: upstream's helpers, plus the list binding this fix reuses to check whether the integration still has credentials.
On the fix itself: auth logout now drops the .well-known/opencode source when the removed credential was the integration's last one, so the cached remote config (models, policies) stops being applied — the fix lives in Credential.remove in core, so it covers every caller, not just the HTTP handler.
Verification at the new head 3e8918fe8e:
bun run check (lint + ast-grep + typecheck across all packages) passes.
packages/core/test/config/config.test.ts — 52 passed; packages/core/test/credential.test.ts + packages/core/test/wellknown.test.ts — 11 passed.
- I have not re-run the server-level
packages/server/test/credential.test.ts after the merge, so that one is unverified at this head; CI covers it.
@rekram1-node @thdxr — the branch is mergeable again; happy to adjust anything before it lands.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
sergiobank
commented
Nov 8, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Still open and mergeable — the fix has not landed on dev (no has on WellKnown.Interface, no well-known handling in Credential.remove there), so this is the only place carrying it.
State at head 3e8918fe8: mergeable: true, mergeable_state: blocked, both required checks (check-compliance, check-standards) pass. The branch is 479 commits behind dev, which is why the conflict handling needed rebasing twice; it merges cleanly now.
Maintainers: this needs a review to land. I will keep resolving conflicts against dev until it does.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks for digging into this and keeping it up to date for so long. Your diagnosis was right. I ended up fixing it in the config loader instead, in #62760: a well-known source with no credential now supplies nothing and its saved config is deleted, so it also covers people who already logged out. That's merged now, with you credited as co-author, so I'm closing this one.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks @rekram1-node !!! Can you merge another fix, this time a one liner fix. #59040
Thank you very much!
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|