Skip to content

fix(cli): enhance error handling for multiple agents in SSH command - #19943

Merged
kacpersaw merged 3 commits into
mainfrom
kacpersaw/bug-ssh-multi-agent-unintuitive
Sep 25, 2025
Merged

kacpersaw merged 3 commits into
mainfrom
kacpersaw/bug-ssh-multi-agent-unintuitive

Conversation

@kacpersaw

Copy link
Copy Markdown

Closes #19812

Problem

When I try to SSH into my workspace with multiple agents. It does not provide an intuitive way to do that successfully and instead misguides by printing wrong instructions.

This PR enhances the error handling to provide suggestions with SSH commands that users can copy and paste directly.

Before:

Encountered an error running "coder ssh", see "coder ssh --help" for more information
error: multiple agents found, please specify the agent name, available agents: [coder dev]

After:

Encountered an error running "coder ssh", see "coder ssh --help" for more information
error: multiple agents found, please specify the agent name, available agents: [coder dev]
Try running:
         $ ssh coder.dogfood.me.coder
         $ ssh dev.dogfood.me.coder

@kacpersaw
kacpersaw marked this pull request as ready for review September 25, 2025 08:31

@ethanndickson ethanndickson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I have one recommendation, but otherwise lgtm & I don't need to review again

Comment thread cli/ssh.go
ws, agent, _, err := GetWorkspaceAndAgent(ctx, inv, client, !disableAutostart, hostname)

ws, agent, otherAgents, err := GetWorkspaceAndAgent(ctx, inv, client, !disableAutostart, hostname)
if err != nil && strings.Contains(err.Error(), "multiple agents found") {

@ethanndickson ethanndickson Sep 25, 2025 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we define the 'multiple agents found' error as a sentinel, and then use errors.Is instead?

@kacpersaw
kacpersaw merged commit c8742ba into main Sep 25, 2025
@kacpersaw
kacpersaw deleted the kacpersaw/bug-ssh-multi-agent-unintuitive branch September 25, 2025 10:03
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 25, 2025
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.

bug: ssh to a multi-agent workspace from CLI is unintuitive

2 participants