Skip to content

fix: infer workspace from env in coder support bundle#24617

Merged
EhabY merged 1 commit into
mainfrom
fix/cli-support-bundle-default-workspace
Apr 22, 2026
Merged

fix: infer workspace from env in coder support bundle#24617
EhabY merged 1 commit into
mainfrom
fix/cli-support-bundle-default-workspace

Conversation

@EhabY
Copy link
Copy Markdown
Contributor

@EhabY EhabY commented Apr 22, 2026

When running coder support bundle inside a workspace without arguments, the command now infers the workspace and agent from the CODER_WORKSPACE_NAME, CODER_WORKSPACE_OWNER_NAME, and CODER_WORKSPACE_AGENT_NAME environment variables set by the workspace agent.

Previously, running without arguments inside a workspace produced an incomplete bundle with no workspace info, agent logs, or connection diagnostics, despite the environment having all the information needed to resolve the current workspace.

Also updates the usage string from <workspace> to [<workspace>] to reflect that the argument has always been optional.

Closes #24615

Note

Generated by Coder Agents

Implementation notes
  • Uses inv.Environ.Get() (testable via inv.Environ.Set()) rather than
    os.Getenv for the new env lookups, consistent with cli/open.go.
  • The existing os.LookupEnv("CODER") warning on line 131 is left as-is
    to avoid unnecessary churn.
  • When env vars are detected, args are injected as owner/workspace and
    the optional agent name, then the existing resolution logic runs
    unchanged.
  • Falls through to the "no workspace specified" warning if env vars are
    missing or incomplete, so behavior is unchanged outside workspaces.

@github-actions
Copy link
Copy Markdown

Docs preview

📖 View docs preview

@EhabY EhabY changed the title fix(cli): infer workspace from env in coder support bundle fix: infer workspace from env in coder support bundle Apr 22, 2026
@EhabY EhabY marked this pull request as ready for review April 22, 2026 13:14
Comment thread cli/support.go Outdated
Copy link
Copy Markdown
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! One suggestion re CODER_WORKSPACE_ID env

When running `coder support bundle` inside a workspace without arguments,
the command now infers the workspace and agent from the CODER_WORKSPACE_NAME,
CODER_WORKSPACE_OWNER_NAME, and CODER_WORKSPACE_AGENT_NAME environment
variables set by the workspace agent.

Previously, running without arguments inside a workspace produced an
incomplete bundle with no workspace info, agent logs, or connection
diagnostics, despite the environment having all the information needed.

Also updates the usage string from `<workspace>` to `[<workspace>]` to
reflect that the argument has always been optional.

Closes #24615
@EhabY EhabY force-pushed the fix/cli-support-bundle-default-workspace branch from 483a3f3 to 985b510 Compare April 22, 2026 13:30
@matifali
Copy link
Copy Markdown
Member

matifali commented Apr 22, 2026

A tangential QQ: does support bundle also runs and includes coder speedtest and coder ping ?

@EhabY
Copy link
Copy Markdown
Contributor Author

EhabY commented Apr 22, 2026

A tangential QQ: does support bundle also runs and includes coder speedtest and coder ping ?

It does not no, and in this case, running coder ping and coder speedtest from inside the workspace is not very informative since it essentially tests the local network there instead of the remote one

@EhabY EhabY merged commit 3362b5a into main Apr 22, 2026
32 checks passed
@EhabY EhabY deleted the fix/cli-support-bundle-default-workspace branch April 22, 2026 14:21
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(cli): coder support bundle should default to current workspace when run inside one

3 participants