fix(cli): don't run the tart backend when tart isn't installed - #11
fix(cli): don't run the tart backend when tart isn't installed#11benlavalley wants to merge 1 commit into
Conversation
|
CodeAnt AI is reviewing your PR. |
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
|
Warning Review limit reached
Next review available in: 54 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughAdds a ChangesTart Availability Gating
Sequence Diagram(s)sequenceDiagram
participant createBackends
participant TartBackend
participant Console
createBackends->>TartBackend: isAvailable()
TartBackend-->>createBackends: true/false
alt unavailable
createBackends->>Console: warn("tart CLI not found")
createBackends->>createBackends: set macos to undefined
end
createBackends->>createBackends: build BackendMap with macos value
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
| if (macos === "tart" && !TartBackend.isAvailable()) { | ||
| console.warn( | ||
| "macOS sandbox backend disabled: the 'tart' CLI was not found on PATH. " + | ||
| "Install tart (https://tart.run) to run macOS sandboxes.", | ||
| ); | ||
| macos = undefined; | ||
| } |
There was a problem hiding this comment.
Suggestion: This change silently unsets the configured macOS backend when Tart is unavailable, which introduces a new runtime path where macOS sandbox requests throw UnsupportedError from backendFor and bubble as uncaught 500s in CreateSandbox (that route does not handle UnsupportedError). Return a controlled error path (for example by surfacing an explicit startup/config error or ensuring request handlers map this case to a non-500 response) instead of silently dropping the backend. [api mismatch]
Severity Level: Major ⚠️
- ❌ POST /sandboxes macOS requests return 500 when backend missing.
- ⚠️ Async sandbox creation with macOS metadata also fails with 500.
- ⚠️ Misconfigured macOS backend silently ignored at startup.Steps of Reproduction ✅
1. Start the server (createApp in cli/src/server/app.ts:30-41) on a host where
config.macosBackend resolves to "tart" (cli/src/server/config.ts:5) but the tart CLI is
not usable or not installed.
2. During startup, createApp calls createBackends (cli/src/server/app.ts:36-41), which
invokes createBackends in cli/src/server/services/backend.ts:65-85.
3. In createBackends, the new block at lines 70-78 detects macos === "tart" and
TartBackend.isAvailable() === false, logs the warning, and sets macos = undefined, so
backends.macos is omitted from the returned BackendMap.
4. A client sends POST /sandboxes with a JSON body whose metadata includes platform:
"macos" (metadata is accepted by CreateSandboxBodySchema in
cli/src/server/controllers/sandboxes/schemas.ts:8-13).
5. The request is handled by CreateSandbox.handle
(cli/src/server/controllers/sandboxes/index.ts:46-58), which calls
sandboxService.create(body) without any try/catch.
6. In SandboxService.create (cli/src/server/services/sandbox.ts:111-121),
resolvePlatform(req.metadata) returns "macos" when metadata.platform === "macos"
(resolvePlatform in cli/src/server/services/backend.ts:88-91), and backendFor("macos")
(cli/src/server/services/sandbox.ts:20-25) finds no macOS backend in this.backends and
throws UnsupportedError("No backend configured for platform \"macos\"").
7. CreateSandbox.handle does not handle UnsupportedError (compare with PauseSandbox and
ResumeSandbox in cli/src/server/controllers/sandboxes/index.ts:166-176 and 214-225, which
explicitly catch UnsupportedError), so the exception bubbles to Hono’s default error
handler and results in an HTTP 500 instead of a controlled 4xx/5xx response indicating
macOS is unsupported or misconfigured.(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** cli/src/server/services/backend.ts
**Line:** 72:78
**Comment:**
*Api Mismatch: This change silently unsets the configured macOS backend when Tart is unavailable, which introduces a new runtime path where macOS sandbox requests throw `UnsupportedError` from `backendFor` and bubble as uncaught 500s in `CreateSandbox` (that route does not handle `UnsupportedError`). Return a controlled error path (for example by surfacing an explicit startup/config error or ensuring request handlers map this case to a non-500 response) instead of silently dropping the backend.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix| static isAvailable(): boolean { | ||
| try { | ||
| execSync("tart --version", { stdio: "ignore", timeout: 5_000 }); | ||
| return true; | ||
| } catch { | ||
| return false; | ||
| } | ||
| } |
There was a problem hiding this comment.
Suggestion: The availability probe treats every failure as “not installed” by catching all exceptions, so transient failures (timeout, permission, execution error) will incorrectly disable Tart and trigger misleading behavior. Restrict the false return to true “command not found” cases and surface/log other failures separately. [incorrect condition logic]
Severity Level: Major ⚠️
- ⚠️ Valid Tart installation misdetected as missing when command errors.
- ⚠️ macOS backend disabled despite Tart being installed and configured.
- ⚠️ Operators see misleading CLI-not-found warning message.Steps of Reproduction ✅
1. Run the server on a macOS host where config.macosBackend resolves to "tart"
(cli/src/server/config.ts:5) and the tart binary exists on PATH but `tart --version` fails
(e.g., exits non-zero, times out >5s, or has a permission issue).
2. On startup, createApp (cli/src/server/app.ts:30-41) calls createBackends
(cli/src/server/services/backend.ts:65-85), passing macos: "tart".
3. Inside createBackends, the condition at cli/src/server/services/backend.ts:72 calls
TartBackend.isAvailable().
4. TartBackend.isAvailable (cli/src/server/services/tart.ts:96-103) runs execSync("tart
--version", { stdio: "ignore", timeout: 5_000 }); when `tart --version` fails for any
reason (non-zero exit, timeout, spawn error), execSync throws, the catch block at lines
100-102 catches all errors, and isAvailable() returns false.
5. Back in createBackends, because isAvailable() returned false, the code at
cli/src/server/services/backend.ts:72-78 logs "the 'tart' CLI was not found on PATH" and
sets macos = undefined, disabling the macOS backend even though the tart binary is present
but misbehaving.
6. Subsequent POST /sandboxes calls that include metadata.platform = "macos" are routed
through CreateSandbox.handle (cli/src/server/controllers/sandboxes/index.ts:46-58) and
SandboxService.create (cli/src/server/services/sandbox.ts:111-121); resolvePlatform
returns "macos", backendFor("macos") throws UnsupportedError because backends.macos is
missing (cli/src/server/services/sandbox.ts:20-24), and the error is not caught in
CreateSandbox, producing a 500 along with a misleading startup log claiming the CLI was
not found.(Use Cmd/Ctrl + Click for best experience)
Prompt for AI Agent 🤖
This is a comment left during a code review.
**Path:** cli/src/server/services/tart.ts
**Line:** 96:103
**Comment:**
*Incorrect Condition Logic: The availability probe treats every failure as “not installed” by catching all exceptions, so transient failures (timeout, permission, execution error) will incorrectly disable Tart and trigger misleading behavior. Restrict the false return to true “command not found” cases and surface/log other failures separately.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix|
CodeAnt AI finished reviewing your PR. |
The macOS sandbox slot defaults to tart regardless of the Linux backend, so a Docker-only Mac still creates a Tart backend that the 30s reconcile loop polls, printing "tart: command not found" on startup and every 30s. Only create the macOS/Tart backend when the tart CLI is on PATH, and capture stderr in tartExec so tart invocations never leak shell errors to the console. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
5efe0e1 to
c12fa66
Compare
User description
The macOS sandbox slot defaults to tart regardless of the Linux backend, so a Docker-only Mac still creates a Tart backend that the 30s reconcile loop polls, printing "tart: command not found" on startup and every 30s.
Only create the macOS/Tart backend when the tart CLI is on PATH, and capture stderr in tartExec so tart invocations never leak shell errors to the console.
CodeAnt-AI Description
Hide Tart errors when the CLI is missing and avoid creating an unusable macOS backend
What Changed
tartCLI is installedImpact
✅ Fewer startup errors on Macs without Tart✅ Cleaner console output during sandbox checks✅ No unusable macOS backend when Tart is not installed💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.
Summary by CodeRabbit
Bug Fixes
Tests