Skip to content

fix(worktrees): worktrees create prints only "The CLI command failed." when the source checkout path doesn't exist - #191237

Closed
yxshee wants to merge 4 commits into
openclaw:mainfrom
yxshee:fix/worktrees-create-missing-repo
Closed

yxshee wants to merge 4 commits into
openclaw:mainfrom
yxshee:fix/worktrees-create-missing-repo

Conversation

@yxshee

@yxshee yxshee commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: openclaw worktrees create <repoRoot> prints only "The CLI command failed. For help, run openclaw doctor." when <repoRoot> doesn't exist (for example a typo), and --json shows only the raw "ENOENT: no such file or directory, realpath ''".

User Impact

User impact: the command now says "Source checkout not found: . Pass the path to an existing git checkout." Exit code is unchanged, and nothing is created.

Why This Change Was Made

worktrees create resolves the source path with realpathSync.native before admission, and the raw ENOENT reached the root failure renderer as an unexpected error. A missing path (ENOENT/ENOTDIR) is now reported with the existing throwExpectedCliError helper; other filesystem errors still propagate as before.

Evidence

Current verification on d8cbceafd1dd9fb8bc63712d739dc103795ce0bd (2026-11-12): merged main at 9ca7932563ff3a8d2d3eca37e50d6ea7b031a527, preserving its consolidated invalid-request cases and newer worktree diagnostics. The PR delta remains two files, +32/-1. Independent source review found no actionable issue in the resolution.

Original CLI before/after proof, unchanged production behavior: built from main at 67416fc on Linux, Node 24.22.2, fresh state directory.

Before:

$ openclaw worktrees create ./my-repo
[openclaw] The CLI command failed.
[openclaw] For help, run `openclaw doctor`.
$ openclaw worktrees create ./my-repo --json
{ "ok": false, "error": { "type": "cli_error", "message": "ENOENT: no such file or directory, realpath './my-repo'" } }

After:

$ openclaw worktrees create ./my-repo
Source checkout not found: ./my-repo. Pass the path to an existing git checkout.
$ openclaw worktrees create ./my-repo --json
{ "ok": false, "error": { "type": "cli_error", "message": "Source checkout not found: ./my-repo. Pass the path to an existing git checkout." } }

Both exit 1, as before.

Tests:

  • pnpm test src/cli/worktrees-cli.test.ts src/cli/worktrees-cli.import-boundary.test.ts --maxWorkers=1: 21 passed on the resolved branch (20 CLI cases plus one import-boundary case). The CLI suite took 57.48 s, including 46.58 s of shared worker preparation; the boundary case took 102 ms.
  • New test "names a missing source checkout instead of failing generically" runs the real formatCliFailureLines path and checks the service is never called. It fails on main and passes with the fix.
  • Current targeted type-aware lint, oxfmt --check, and PR-delta whitespace checks on both files: clean. Fresh CI applies to the pushed head; prior-head CI is not counted as current-head proof.

@clawsweeper

clawsweeper Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: XS labels Nov 2, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 2, 2026
@clawsweeper

clawsweeper Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Report an actionable error when worktree creation receives a nonexistent source checkout path.

Example: Run openclaw worktrees create ./my-repo when ./my-repo does not exist.

  • Before: The CLI prints a generic failure and suggests Doctor.
  • After: The CLI prints Source checkout not found: ./my-repo. Pass the path to an existing git checkout. and exits 1.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful, focused, and demonstrated through the shipped CLI; exact-head broad CI remains unexecuted pending workflow approval.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The supplied built-CLI trace exercises nonexistent checkout creation in human and JSON modes on Linux with fresh state and shows the actionable message with unchanged exit 1; the diagnostic implementation remains unchanged at this head.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A mistyped checkout path produces an unhelpful generic failure instead of explaining which input to correct.
Reason: The bounded diagnostic repair makes an existing refusal actionable while preserving successful operations and owner admission.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR fixes a current diagnostic bug with a focused patch and convincing CLI proof; no actionable code findings remain, but current-head CI awaits workflow approval.

Priority: P3
Reviewed head: e146b4b8a38c1ebc04436aa36d0addff890cbdeb

Before merge

  • Await maintainer action - Approve the pending GitHub Actions workflows for head e146b4b.

Findings

None.

Agent review details

How this fits together

The worktree CLI resolves the supplied checkout before dispatching creation through the local state owner; expected input errors reach the shared human and JSON failure renderers.

flowchart TD
  A[Worktrees create command] --> B[Resolve source checkout]
  B --> C[Expected CLI error]
  C --> D[Human or JSON failure output]
  B --> E[Local state owner]
  E --> F[Managed worktree service]
Loading

Technical review

Best possible solution:

Merge the focused error translation once approved current-head workflows satisfy the existing CI gate.

Do we have a high-confidence way to reproduce the issue?

Current-main source exposes the raw missing-path exception before admission, and the contributor supplies matching built-CLI before/after output; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch fixes classification at the CLI producer using the existing expected-error owner, preserves native path semantics and unrelated errors, and adds a useful boundary regression without unnecessary machinery.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 97dd78cc2cbd.

Provenance checked

  • Source checkout resolution before owner admission keeps the original intent (1b08795: Resolve the physical repository and capture its identity before routing creation through the live state owner.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Focused introduced patch: The pinned introduction adds missing-path classification around native realpath resolution and one regression exercising command parsing and the real failure renderer. (src/cli/worktrees-cli.ts:80, e146b4b8a38c)
  • Current main still needs the fix: Creation still calls realpathSync.native directly before admission; the shared renderer hides unexpected filesystem errors in ordinary human output. (src/cli/worktrees-cli.ts:187, 97dd78cc2cbd)
  • Supplied shipped CLI proof: The full PR body records built-CLI before/after output on Linux with Node 24.22.2 and fresh state, covering human and JSON missing-path failures with exit 1; comparison with the earlier reviewed head confirms the production fix is unchanged. (e146b4b8a38c)
  • Current-head CI has not executed: The CI workflow reports action_required for the exact head and has zero jobs; the failed openclaw/ci-gate therefore does not establish a patch-caused test failure. (e146b4b8a38c)
  • Original physical-path contract preserved: The routing change introduced native physical path resolution to preserve symlink and parent-directory semantics before owner admission; this PR retains that operation and its downstream identity checks. (src/cli/worktrees-cli.ts:187, 1b08795ae494)
  • Related merged repair excludes this work: fix(cli): preserve existing proxy and transcript error reasons #191295 explicitly excludes this source-checkout diagnostic and fixes separate proxy and transcript errors. (fced9054e725)

Likely related people:

  • Jason (Json): Raw commit 5f3ca5a adds src/cli/worktrees-cli.ts:78 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5f3ca5a8553d; files: src/cli/worktrees-cli.ts)

PR surface

Source +14, Tests +18. Total +32 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 15 1 +14
Tests 1 18 0 +18
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 33 1 +32

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • remove rating: 🦞 diamond lobster: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on maintainer.

Label justifications:

  • P3: This improves diagnostics for a mistyped path in an advanced CLI workflow without changing successful creation or exit status.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-02T16:13:10.672Z sha 82563ef :: needs maintainer review before merge. :: none
  • reviewed 2026-11-08T21:48:49.584Z sha 2fc7a5d :: needs maintainer review before merge. :: none

Reviewed November 15, 2026, 12:33 PM ET / 17:33 UTC (Revision 3).

…tion

Use hasErrnoCode instead of casting the caught error to NodeJS.ErrnoException, so the assertion-safety ratchet has no new uncommented assertion to flag.
@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Nov 4, 2026
@yxshee

yxshee commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 8, 2026
@obviyus

obviyus commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 15, 2026
@obviyus

obviyus commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the work here. We're closing this along with the author's other open PRs: the series splits one kind of change across many commands or call sites, and much of it is backed only by issues filed by the same author. Please open one issue per root cause with a reproduction from a real affected setup; maintainers will decide scope and fix it once at the shared owner.

@obviyus obviyus closed this Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawtributors PR from a clawtributor cli CLI command changes P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants