GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||
GeezerVison is showing github.com — fix(core): drop logged-out wellknown endpoints instead of wiring empty api keys by nosmile99 · Pull Request #54687 · anomalyco/opencode Conversation
|
|
The following comment was made by an LLM, it may be inaccurate: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I reproduced #54645 on the base with the issue's two-endpoint script against opencode serve from source. After logging out of B, the gateway got x-api-key="" and returned 401, also after a restart. With this PR it gets key-a in both cases. The core config tests and typecheck pass, and the new test fails on the base as it should.
Public API: unchanged.
The fix itself looks right. Two things are worth addressing (see the inline comments):
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| // A failed refresh with a credential present keeps the last resolved config so | ||
| // remote providers and allowlists do not disappear; only removing the source | ||
| // clears it. | ||
| if (auth && !variables) return [] |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This partly reverts #53667 (f108fa492), which deliberately kept an endpoint's last config even with no credential. Its comment said "including a missing credential", and the aim was that remote providers and enabled_providers/policies would not disappear. After this change, logging out of an endpoint also drops its allowlist and provider-use policies, not just the header that can no longer resolve. That probably matches what logout should mean, but please say so in the description so maintainers can confirm the trade-off. A narrower alternative would keep the cached config and skip only the values whose {env:} cannot be resolved.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Fair point — stating the trade-off explicitly (also added to the PR description):
What changes: after auth logout, the endpoint contributes no documents, so its cached config — including allowlist and provider-use policies — drops from the effective config until re-login. That is a deliberate narrowing of #53667, not an accident.
Why the split is principled: #53667's intent (a failed refresh must not make remote providers/allowlists disappear) is preserved — when the credential exists but the remote fetch fails, variables is still defined and the cached config keeps being used. The new return [] only fires when there is no credential at all (auth declared, credentials.list empty), i.e. after logout. In that state the endpoint cannot authenticate any request, so keeping its documents only preserves the #54645 shadowing vector: the empty-substituted header overlays the still-authenticated endpoint's wiring (later document wins in mergeHeaders → 401s surviving restarts).
Why not the narrower alternative (keep cached config, skip only the header): the shadowing is not limited to the key header — any field of the stale cached document overlays the live endpoint's — and listing models that cannot authenticate is worse UX than removing them until auth login re-resolves everything (policies included). Logout meaning "the endpoint is gone from the effective config" is the coherent semantic here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that matches the code. The early return [] only applies when auth is required and there's no usable key, so a failed refresh with a credential still falls back to wellknown.cached. The case #53667 protects is unchanged. With the trade-off now stated in the description, whether logout should also drop the endpoint's policies is a decision for maintainers. I have nothing further on this point.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| return Layer.mergeAll(built, Watcher.testLayer) | ||
| } | ||
|
|
||
| it.live( |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This file is about 200 lines, mostly a copy of the KV/Credential/Bus setup in config.test.ts, to check one assertion. The changed expectation in config.test.ts (toEqual(removed) after logout) already covers logout dropping the endpoint's documents. Could you either drop this file or turn it into a short two-endpoint case next to the existing test? The aim is to keep the change small.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done in 2020b9f — the standalone 197-line file is gone; the regression is now a compact two-endpoint case inside config.test.ts next to the existing logout test, reusing its fixtures. 43/43 tests pass in that file.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I checked 2020b9f. The separate file is gone, and the source change is the same as the one I verified. The new case is shorter, but it's still about 130 lines: it builds its own servers, credential mock and layer rather than reusing the existing logout test's fixtures. It's fine if maintainers are happy with that size. Since the existing test's toEqual(removed) already covers logout, a much smaller case would be enough.
The point I raised on config.ts is still open. Logging out now drops the endpoint's whole cached config, including its enabled_providers and policies. #53667 deliberately kept that config. A sentence in the PR description saying this is intended would help maintainers decide.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…mpact two-endpoint case Replace the standalone 197-line wellknown-stale-wiring.test.ts with a shorter two-endpoint case next to the existing logout test, reusing its fixture pattern. Also documents the logout trade-off: a logged-out endpoint drops its allowlist/provider-use policies too, not just the unresolvable header.
|
Thanks for the review — both addressed in 2020b9f: Test size: dropped the standalone 197-line Revert-of-#53667 trade-off: you're right that this partly reverts f108fa4. The deliberate behavior there (keep last config "including a missing credential") is exactly what produced #54645: after logout, the stale document's |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
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:
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. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
providers: stale wellknown API-key wiring in the shared service sends an empty key after auth login/logout
There was an error while loading. Please reload this page.