Skip to content

fix: don't panic on git credentials requests during setup - #3

Open
renatoathaydes wants to merge 1 commit into
mainfrom
claude/port-bug-fix-fork-a0f01a
Open

renatoathaydes wants to merge 1 commit into
mainfrom
claude/port-bug-fix-fork-a0f01a

Conversation

@renatoathaydes

Copy link
Copy Markdown
Collaborator

Problem

devpod up crashes the local CLI when the container asks for git credentials during setup, for example from a postStartCommand that clones over HTTPS:

panic: runtime error: invalid memory address or nil pointer dereference
github.com/loft-sh/devpod/pkg/agent/tunnelserver.(*tunnelServer).GitCredentials
	pkg/agent/tunnelserver/tunnelserver.go:233

RunSetupServer creates the tunnel server without a workspace, but GitCredentials reads t.workspace.Source.GitRepository whenever platform options are not enabled. The workspace never starts, because every up crashes at the same lifecycle command.

Changes

  • pkg/devcontainer/setup.go: pass the workspace to the setup tunnel server, so setup-time git credential requests get the repository's path again, as they do on the other tunnel servers.
  • pkg/agent/tunnelserver/tunnelserver.go: skip the repository lookup when there is no workspace, as the other handlers in that file already do.
  • New TestGitCredentials_NoWorkspace. It panics without the guard and passes with it. It points git at empty config so it never reaches the host's credential helpers.

Testing

  • go vet, gofmt and go test pass for ./pkg/agent/tunnelserver/ ./pkg/devcontainer/.
  • End to end on docker-desktop Kubernetes (arm64), with the kubernetes provider. The source was a git SSH URL whose devcontainer has a Dockerfile build, features, and a postStartCommand that clones over HTTPS:
    • Before: up exited 2 with the panic above.
    • After: up exits 0. Both /git-credentials requests are answered and every lifecycle command runs.
    • The agent in the pod was this branch's build. Its SHA-256 matched the local build, and DEVPOD_AGENT_URL pointed at an address nothing listens on, so no release could be downloaded.

The same code is in loft-sh/devpod main.

🤖 Generated with Claude Code

The setup tunnel server was created without the workspace, so a git
credentials request from the container during setup, e.g. a
postStartCommand that clones over HTTPS, dereferenced a nil workspace
in GitCredentials and crashed the local CLI.

Pass the workspace to the setup server and guard the lookup against a
nil workspace, as the other handlers already do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@renatoathaydes
renatoathaydes force-pushed the claude/port-bug-fix-fork-a0f01a branch from 6f2f76c to 7c1bec9 Compare October 11, 2026 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant