Skip to content

fix(ide): propagate in-container setup failures instead of panicking#456

Merged
skevetter merged 1 commit into
mainfrom
fix/jupyter-ide-opener-nil-pointer
May 28, 2026
Merged

fix(ide): propagate in-container setup failures instead of panicking#456
skevetter merged 1 commit into
mainfrom
fix/jupyter-ide-opener-nil-pointer

Conversation

@skevetter

Copy link
Copy Markdown
Contributor

Summary

Creating a workspace with the Jupyter Notebook IDE on a container without Python (e.g. vscode-remote-try-node) panicked the CLI:

panic: runtime error: invalid memory address or nil pointer dereference
goroutine 1 [running]:
github.com/devsy-org/devsy/pkg/ide/opener.openBrowserIDE(...)
    pkg/ide/opener/opener.go:311

Root cause: the in-container jupyter install failed (no pip in a Node image), the inner agent exited non-zero without sending a structured result, the host received a half-populated Result with a nil SubstitutionContext, and openIDE nil-derefed accessing ContainerWorkspaceFolder.

Three-layer fix:

  • cmd/agent/container/setup.go — new reportSetupFailure sends Result{Error: cause} through the tunnel on setup failure (pre-attach or post-attach), so the underlying cause survives the SSH boundary instead of collapsing to a generic SSH exit-code wrapper.
  • cmd/agent/workspace/up.goup() now surfaces a forwarded result.Error as a non-zero process exit. Pre-existing send-failure log upgraded from Debug to Error and now includes the original cause.
  • cmd/up/up.go — host-side executeDevsyUp rejects results missing SubstitutionContext with a clear error, so a future regression won't reach openIDE with a half-populated result.
  • pkg/ide/opener/opener.govalidateOpenParams guards the dispatcher; nil Result or SubstitutionContext produces a descriptive error naming the IDE before any per-IDE handler runs.

After the fix, the same scenario surfaces as: start workspace: seems like neither pip3 nor pip exists, please make sure to install python correctly — flowing through the existing WriteErrorJSON envelope to the desktop frontend.

Added TestOpen_NilResultRejected covering nil Result and nil SubstitutionContext across browser (jupyter, openvscode) and desktop (vscode) dispatch paths to pin the original crash.

When an IDE install inside the container failed (e.g. Jupyter on a Node
image with no pip), the inner agent exited non-zero without sending a
structured result, the host received a half-populated Result with a nil
SubstitutionContext, and openIDE nil-derefed on
ContainerWorkspaceFolder.

Three-layer defense:
- Inner agent now sends Result{Error: ...} via the tunnel on setup
  failure, so the underlying cause survives the SSH boundary.
- Outer agent surfaces a forwarded result.Error as a non-zero exit.
- Host validates SubstitutionContext and opener guards against nil
  Result before dispatching to any per-IDE handler.

Send-failure logs upgraded from Debug to Error and include the original
cause so a failure-on-failure leaves a breadcrumb.
@netlify

netlify Bot commented May 28, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit d940311
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a186b6a1e77300008b29967

@coderabbitai

coderabbitai Bot commented May 28, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@skevetter, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 32 minutes and 44 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 340a8ad9-848f-432c-b236-682d6c5a7af1

📥 Commits

Reviewing files that changed from the base of the PR and between e8ee7f4 and d940311.

📒 Files selected for processing (5)
  • cmd/agent/container/setup.go
  • cmd/agent/workspace/up.go
  • cmd/up/up.go
  • pkg/ide/opener/opener.go
  • pkg/ide/opener/opener_test.go

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 and usage tips.

@skevetter
skevetter marked this pull request as ready for review May 28, 2026 16:44
@skevetter
skevetter merged commit 4b0a235 into main May 28, 2026
98 of 100 checks passed
@skevetter
skevetter deleted the fix/jupyter-ide-opener-nil-pointer branch May 28, 2026 17:30
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