GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: refresh CLI credentials before each invocation by EhabY · Pull Request #926 · coder/vscode-coder

Conversation

@EhabY

@EhabY EhabY commented Apr 30, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator
  • Refresh the credential file (or keyring on supported systems) before each CLI call by awaiting cliManager.configure inside commands.ts:resolveCliEnv. The CLI reads the fresh token via the existing --global-config / --url flags. mTLS still works since the refresh accepts an empty token.
  • Stop wrapping AbortError inside cliError. Previously, wrapping replaced the AbortError name with stale CLI stderr, so cancellations from speedtest and support bundle looked like real failures to withCancellableProgress.
  • Tighten isAbortError to narrow to Error so callers can return the error directly.
  • Drop the unused keyringOnly option from storeToken.
  • Add writeStdoutJs / writeStderrJs test helpers that wrap fs.writeSync. Fixes a flaky version-fallback test caused by lost async pipe writes on exit (see https://nodejs.org/api/process.html#a-note-on-process-io).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@EhabY EhabY self-assigned this Apr 30, 2026
EhabY added 2 commits April 30, 2026 18:52
@EhabY
fix: forward auth env to coder CLI child processes
19bc1aa
Pass CODER_URL and CODER_SESSION_TOKEN to every CLI child (speedtest,
support bundle, ping, app status terminal). An empty token is valid and
covers mTLS. This is in addition to the existing --url / --global-config
flags so subprocesses the CLI itself spawns also see the auth.

Also stop wrapping AbortError in cliError. Wrapping replaced the
AbortError name with stale CLI stderr, making cancellations look like
real failures. Tighten isAbortError to narrow to Error so callers can
return it directly.
@EhabY
reformat cliExec
c820189
@EhabY
EhabY force-pushed the forward-auth-env-to-cli branch from 5944f8c to c820189 Compare April 30, 2026 15:52
@EhabY

EhabY commented Apr 30, 2026

Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

coder-agents-review[bot] reacted with rocket emoji
All reactions
  • 🚀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

coder-agents-review[bot]
coder-agents-review Bot reviewed Apr 30, 2026
View reviewed changes

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown

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.

Three P3s, two nits. No blockers.

The env forwarding is sibling-complete: all four cliExec.ts call sites get the same buildChildEnv treatment. The mTLS empty-token edge case has its own test. The AbortError analysis is grounded in code structure (traced isExecFileException matching AbortError.code), not asserted from intuition. The isAbortError type narrowing from boolean to error is Error is a prerequisite for the cliError return, not scope drift. Commit hygiene is solid: functional change and reformat are separate commits.

"I tried four different framings of the problem and the author's framing survived all of them." (Pariston)

The main gap is that the AbortError fix (the PR's second bullet) ships without a test proving it works. The createTerminal env semantics mismatch is a real bug in one of the four call sites. And runCliCommand in workspace.ts is a sibling CLI spawn site that the PR's "every" claim misses.

PS. The reformat commit subject (reformat cliExec) doesn't follow the project's type(scope): message format; should be refactor: reformat cliExec or similar.


src/core/cliExec.ts:238

Nit [DEREM-2] banner is now required (string[], line 192), so if (options.banner) always evaluates to true (even an empty array is truthy). The guard can be removed, keeping only the loop body. (Netero)

🤖

src/api/workspace.ts:70

P3 [DEREM-4] runCliCommand spawns coder start/coder update via spawn(cmd, { shell: true }) with no env override. Same class of CLI child process as the four fixed in cliExec.ts.

"CliContext at workspace.ts:48 is a sibling of CliEnv at cliExec.ts:14. Both wrap 'how to invoke the coder binary.' The PR adds authEnv and buildChildEnv to CliEnv, but runCliCommand uses CliContext which has no authEnv field." (Robin)

The CLI flags still carry auth for the direct binary, so nothing breaks today. The gap matters for nested subprocesses that coder start/coder update might spawn. The PR description says "every coder CLI child process"; these two are not covered. (Kite P3, Robin P3, Hisoka P4)

🤖

🤖 This review was automatically generated with Coder Agents.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/core/cliExec.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/core/cliExec.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/error/errorUtils.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/core/cliExec.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@EhabY
fix(cliExec): pass only auth delta to createTerminal
357814b
createTerminal({env}) merges additively on top of the user's terminal
env, so spreading process.env was clobbering platform settings like
terminal.integrated.env.linux. Split the env builder so execFile/spawn
get the full process.env overlay and createTerminal only gets the
CODER_URL/CODER_SESSION_TOKEN delta.

Also:
- Add unit tests for isAbortError covering the DOMException path.
- Add a speedtest test asserting AbortError survives cancellation.
- Rename CliEnv.authEnv to childCredentials to disambiguate from CliEnv.auth.
- Remove the always-true banner guard in spawnCliInTerminal.
@EhabY

EhabY commented Apr 30, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator Author

DEREM-2: Done in 357814b.

DEREM-4: Skipping. The direct binary already has auth via flags, and coder start/coder update are short-lived calls we have no evidence spawn auth-needing children. Capturing {url, token} here would also break the refresh-resilience cliAuth has by design (it never carries a token). Scoped the PR description to the four cliExec.ts call sites.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@EhabY EhabY changed the title fix: forward auth env to coder CLI child processes fix: refresh CLI credentials per call instead of forwarding via env Apr 30, 2026
@EhabY EhabY changed the title fix: refresh CLI credentials per call instead of forwarding via env fix: refresh CLI credentials before each invocation Apr 30, 2026
@EhabY
EhabY requested a review from code-asher April 30, 2026 20:32
@EhabY
EhabY force-pushed the forward-auth-env-to-cli branch from 185abc4 to 0ca0170 Compare April 30, 2026 20:42
code-asher
code-asher approved these changes Apr 30, 2026
View reviewed changes
Comment thread src/login/loginCoordinator.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@EhabY
fix(cliExec): refresh credentials per CLI call instead of env-forwarding
c104424
Forwarding CODER_SESSION_TOKEN via the child env exposed it to any
sibling process via /proc/<pid>/environ on Linux and similar interfaces
elsewhere. Drop all env injection from cliExec and instead refresh the
file or keyring once via cliManager.configure inside resolveCliEnv,
mirroring the connection-time write in remote.ts. The CLI reads the
fresh token from the file (or keyring on supported systems) via the
existing --global-config / --url flags. mTLS still works since the
refresh accepts an empty token.

Also drop the keyringOnly option from storeToken (no longer needed now
that we always refresh) and update the matching tests.

Add writeStdoutJs / writeStderrJs helpers in test/utils/platform.ts that
generate fs.writeSync snippets, and use them in the cliExec and platform
tests. process.stdout/stderr.write is async on POSIX pipes and can be
lost on exit (nodejs/node#4112), which was making the version fallback
test flaky.
@EhabY
EhabY force-pushed the forward-auth-env-to-cli branch from 0ca0170 to c104424 Compare April 30, 2026 20:49
@EhabY
EhabY merged commit 207d11e into main Apr 30, 2026
10 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@EhabY
EhabY deleted the forward-auth-env-to-cli branch April 30, 2026 20:53
@EhabY EhabY mentioned this pull request May 18, 2026
Add alternativeWebUrl param #956
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@code-asher code-asher code-asher approved these changes
+1 more reviewer
@coder-agents-review coder-agents-review[bot] coder-agents-review[bot] left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@EhabY EhabY

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@EhabY @code-asher
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.