Skip to content

Fix --clone flag not working when starting workspace#34

Merged
gricha merged 1 commit intomainfrom
fix-clone-flag
Jan 7, 2026
Merged

Fix --clone flag not working when starting workspace#34
gricha merged 1 commit intomainfrom
fix-clone-flag

Conversation

@gricha
Copy link
Copy Markdown
Owner

@gricha gricha commented Jan 7, 2026

Summary

  • Fixed the --clone flag not working when starting a workspace with perry start <name> --clone <url>
  • The root cause was that the container's init command (which handles git cloning) was never being called during container startup
  • Added integration test that verifies the repository is actually cloned inside the workspace

Changes

  • perry/internal/src/commands/entrypoint.ts: Call runInit() after Docker daemon is ready
  • test/integration/cli.test.ts: Enhanced clone test to wait for init completion and verify the repo exists

Test plan

  • bun run validate passes
  • Manual test: perry start test-clone --clone https://github.com/octocat/Hello-World creates workspace with cloned repo
  • Integration test verifies .workspace-initialized marker exists and Hello-World/.git directory is present

🤖 Generated with Claude Code

The clone flag was being passed correctly through the CLI and API,
and the container was receiving the WORKSPACE_REPO_URL environment
variable, but the init script that handles cloning was never being
called during container startup.

Changes:
- Call runInit() in the container entrypoint after Docker is ready
- Add integration test that verifies repository is actually cloned
- Test waits for .workspace-initialized marker before checking

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Comment on lines +22 to +23
console.log("[entrypoint] Running workspace initialization...");
await runInit();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The call to await runInit() in the container entrypoint lacks error handling, which can cause an infinite container restart loop on initialization failure, preventing SSH access.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

The runEntrypoint function calls await runInit() without a try...catch block. If runInit() throws an error, for instance due to a failed git clone or a failing bootstrap script, the exception is not caught locally. This causes the entire container process to exit. Because the container is configured with a restartPolicy: 'unless-stopped', Docker will immediately restart it, leading to an infinite loop of startup, failure, and restart. The SSH daemon is started after runInit(), so this failure loop prevents it from ever running, making the workspace inaccessible for debugging.

💡 Suggested Fix

Wrap the await runInit() call within a try...catch block. In the catch block, log the initialization error but do not exit the process. This will allow the container to finish starting up and enable the SSH daemon, letting users connect to the workspace to diagnose the problem.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: perry/internal/src/commands/entrypoint.ts#L22-L23

Potential issue: The `runEntrypoint` function calls `await runInit()` without a
`try...catch` block. If `runInit()` throws an error, for instance due to a failed git
clone or a failing bootstrap script, the exception is not caught locally. This causes
the entire container process to exit. Because the container is configured with a
`restartPolicy: 'unless-stopped'`, Docker will immediately restart it, leading to an
infinite loop of startup, failure, and restart. The SSH daemon is started after
`runInit()`, so this failure loop prevents it from ever running, making the workspace
inaccessible for debugging.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 8299098

@gricha gricha merged commit 590faa7 into main Jan 7, 2026
6 checks passed
@gricha gricha deleted the fix-clone-flag branch January 7, 2026 19:33
gricha added a commit that referenced this pull request Jan 7, 2026
Addresses Sentry review feedback on PR #34. If runInit() throws
(e.g., git clone fails), the container would crash and restart
infinitely, preventing SSH access for debugging.

Now initialization failures are caught and logged as non-fatal,
allowing the SSH daemon to start so users can connect and debug.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
gricha added a commit that referenced this pull request Jan 7, 2026
Addresses Sentry review feedback on PR #34. If runInit() throws
(e.g., git clone fails), the container would crash and restart
infinitely, preventing SSH access for debugging.

Now initialization failures are caught and logged as non-fatal,
allowing the SSH daemon to start so users can connect and debug.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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