Repository navigation
fix(cli): remove the local target; unset WEGO_TARGET=local before upgrading - #51
Merged
Merged
Conversation
The `local` target existed so a developer could point the CLI at an apps/api on their own machine. `WEGO_API_URL` already does that on the default `prod` target — the endpoint override path accepts a plaintext `http` URL for loopback — so the target was a second way to say the same thing, and the only one of the three that could throw from inside `targetEndpointOverrides`. Deletions, plus one widening that keeps the replacement whole: the plaintext exception in `config.ts` knew only `localhost`, `127.0.0.1` and `[::1]`, while the departing `isLocalApiUrl` also accepted the reserved `.localhost` suffix — which is what portless serves the local apps/api at (`api.localhost`), and what a linked worktree gets a branch-prefixed name under. `isLoopbackHost` carries that suffix over, so every shape a developer actually has still works over `http`, and nothing else does: RFC 6761 reserves the suffix for loopback, so no routable host can claim it. A remote plaintext endpoint is still refused, because the access token travels to whatever that URL names. `targetEndpointOverrides` loses its `apiUrlEnvValue` parameter with the branch that read it, and its message now says "loopback" rather than "localhost", which `api.localhost` is not. `--target local` is now the ordinary unknown-value usage error, exit 2, naming the list it must be one of. That is the axis behaving as designed — a mistyped target has always been loud rather than a silent fall back to prod. Part of wego/foundations#127, Phase 4, step 2 (wego/foundations#136). That issue also retires the flavor axis; this is the `local` half only. The flavor half touches `installScope` and `legacyScopeDir`, which decide where an existing install's config and binary live, so it is a migration surface rather than a deletion and gets its own change. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QqBtLcUgxavCqnmSv5rPyd
sunny-wego
requested review from
chuyeowego and
yeouchien-wego
as code owners
September 15, 2026 07:44
Two comments in release-cli.yml name a target this branch removes. They are comments, so nothing runs differently; left alone they would describe the axis wrongly from the moment this merges. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QqBtLcUgxavCqnmSv5rPyd
An exported WEGO_TARGET=local becomes an unknown target the moment this release lands, and an unknown target is refused at startup — so every command, `wego update` included, exits 2 until it is unset. Getting to the release is safe (the old binary does the update and still knows the value), and recovery is one `unset`, but nothing told the person that. The README's configuration section is where someone looks for what the variable takes, so the note lives beside the row rather than in a changelog they have already scrolled past. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QqBtLcUgxavCqnmSv5rPyd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Part of wego/foundations#127, Phase 4, step 2 (wego/foundations#136) — the
localhalf of it.Release note
The PR title is written to carry that warning because it is the release note: this repo squash-merges, the squash subject becomes the changelog line release-please puts in the GitHub Release, and a PR with more than one commit takes that subject from the title. The fuller version lives in the README's configuration section, next to the variable it concerns.
What
--target localis gone.TARGETSisprod | staging.The target existed so a developer could point the CLI at an
apps/apion their own machine.WEGO_API_URLalready does that on the defaultprodtarget, so the target was a second way to say the same thing — and the only one of the three that could throw from insidetargetEndpointOverrides.The one thing that is not a deletion
The replacement path had a gap, and this closes it rather than leaving it.
config.ts's plaintext-httpexception knew three literals:localhost,127.0.0.1,[::1]. The departingisLocalApiUrlalso accepted the reserved.localhostsuffix — which is exactly what portless serves the localapps/apiat (api.localhost), and what a linked worktree gets a branch-prefixed name under. Without carrying that over, removinglocalwould have broken every developer whose setup is portless.isLoopbackHostcarries it over, and no further:http://localhost:3001http://127.0.0.1:4321http://api.localhosthttp://rung2-api.localhosthttp://localhost.evil.comhttp://api.wego.comRFC 6761 reserves the whole
.localhostsuffix for loopback, so nothing routable can claim it. A remote plaintext endpoint stays a configuration error — the access token travels to whatever that URL names. The message now says "loopback" rather than "localhost", whichapi.localhostis not.Does this endanger
wego update?No, and the specific paths were checked rather than assumed.
update.tsimports exactly one symbol from anything this PR touches:assertSecureUrl. Ring following, manifest fetch, checksum verification, Sigstore identity checks and binary replacement are untouched.update.ts:390) is a widening, so it cannot turn away a URL that previously passed.install.jsonrecords the ring, and an install with no recorded ring refuses to update rather than guess. It cannot move: the oldtargetEndpointOverridesreadapiUrlEnvValueonly insidecase "local", so forprodandstagingthe returned bundle is identical andtargetConfigScope(...)output is byte-identical.installScopeandlegacyScopeDirare untouched.ring-follow.ts:40) holdsringandinstallUrlonly — notargetfield, so there is no persisted"local"on disk for a new binary to reject.local.Also
targetEndpointOverridesloses itsapiUrlEnvValueparameter along with the branch that read it.prod|staging|localnow spell itprod|staging, including thebuild-release.tserror a stale caller sees and two comments inrelease-cli.yml..env.local.examplesay to setWEGO_API_URLfor a local API, andWEGO_API_URLjoins the README's runtime-variable table, which had not listed it.Behaviour change
Exit 2 — the ordinary unknown-value usage error. That is the axis behaving as designed: a mistyped target has always been loud rather than a silent fall back to prod. Nothing else changes —
prodstill imposes nothing,stagingstill imposes its whole bundle, credentials are still keyed by the auth host that issued them.Checks
bun test— 1473 pass, 0 fail, offline. Same count asmain: two tests retired with the target, two added for the replacement path.bun run lint— exit 0 (7 pre-existing warnings, none in the touched files).bun run typecheck— exit 0.--target localexits 2;WEGO_API_URL=http://localhost:3001 wego info targetresolvesprod (default)withapi http://localhost:3001;WEGO_API_URL=http://api.localhost wego whoamigets past the transport check,http://api.wego.comdoes not;WEGO_TARGET=local wego updateexits 2 with the message quoted in the release note.Not in this PR
wego/foundations#136 also retires the flavor axis. That half touches
installScopeandlegacyScopeDir— the code that decides where an existing install's config directory and binary live — so it is a migration surface rather than a deletion, and gets its own change.🤖 Generated with Claude Code
https://claude.ai/code/session_01QqBtLcUgxavCqnmSv5rPyd