Skip to content

fix(tunnel): surface agent command failure instead of masking it#646

Draft
skevetter wants to merge 1 commit into
mainfrom
fix/error-output-clarity
Draft

fix(tunnel): surface agent command failure instead of masking it#646
skevetter wants to merge 1 commit into
mainfrom
fix/error-output-clarity

Conversation

@skevetter

Copy link
Copy Markdown
Contributor

Summary

Fixes a misleading error surfaced during workspace up: when the in-container agent failed a stage after sending its result over the tunnel (e.g. a failed git clone), the CLI reported

start workspace: save workspace result: workspace <id> no longer exists

instead of the real cause. The "no longer exists" message is a downstream symptom — the agent's failure-cleanup had already removed the workspace directory, and up then tripped over the missing directory while saving the result.

Root cause

ClassifyTunnelErrors discarded the tunnel (agent command) error whenever the handler side completed cleanly:

if handlerErr == nil {
    return nil   // agent command error thrown away
}

In the SSH/local path (docker/podman), the agent sends its result over gRPC and then may fail a later stage. The handler (result receiver) sees a clean completion, so handlerErr == nil and the agent's real exit error (tunnelErr) was dropped. ExecuteCommand then returned (result, nil), up proceeded to SaveWorkspaceResult, found the directory already removed by the agent's cleanup, and reported the misleading message.

Fix

Surface a permanent tunnel error when the handler returns nil, reusing the existing ClassifyError so normal shutdown/EOF completions still resolve to nil:

if handlerErr == nil {
    if ClassifyError(tunnelErr) == ErrorPermanent {
        return fmt.Errorf("agent command: %w", tunnelErr)
    }
    return nil
}

Before / after

Reproduced on a real Fedora host with rootless podman by cloning an unresolvable repo:

  • Before: start workspace: save workspace result: workspace notfound-devsy-sh no longer exists
  • After: start workspace: tunnel to container: agent command: run agent command failed: exit status 128 ...

Notes

  • The proxy path already surfaced the agent error correctly; only the SSH/local path had the masking bug.
  • Two cosmetic issues remain on this error path and are intentionally left for follow-up: the agent's generic "Command failed with exit code N" line is captured into the message tail (rather than the causal line), and the failure-cleanup path emits a secondary credential-helper warning. The primary confusion — the wrong root cause — is resolved here.

ClassifyTunnelErrors discarded the tunnel (agent command) error whenever
the handler side completed cleanly. When the in-container agent sent its
result over gRPC and then failed a later stage (e.g. git clone), the
handler saw a clean completion (nil) so the real exit error was dropped.
`up` then proceeded to save the workspace result, found the directory
already removed by the agent's failure cleanup, and reported the
misleading "workspace X no longer exists" instead of the real cause.

Surface a permanent tunnel error when the handler returns nil, reusing
ClassifyError so normal shutdown/EOF completions still resolve to nil.
@netlify

netlify Bot commented Jul 10, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit 519e1a6
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a5156ccebbaaf00085f6eef

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5b742d31-6907-42bc-a5e2-793a8cc0e471

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@netlify

netlify Bot commented Jul 10, 2026

Copy link
Copy Markdown

Deploy Preview for images-devsy-sh canceled.

Name Link
🔨 Latest commit 519e1a6
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a5156cc6d8c1600080261f2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant