Skip to content

fix(worktrees): explain session creation failures for repositories without commits - #140251

Merged
obviyus merged 2 commits into
openclaw:mainfrom
SunnyShu0925:fix/worktree-error-message-140204
Sep 7, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
SunnyShu0925:fix/worktree-error-message-140204

Conversation

@SunnyShu0925

@SunnyShu0925 SunnyShu0925 commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes #140204

What Problem This Solves

Creating a worktree session in an initialized Git repository with no commits incorrectly reports that the folder is not a Git checkout.

Why This Change Was Made

Preserve the repository service's specific diagnostic through the shared session-preparation path. Add the instruction to create an initial commit and retry at the existing missing-commit check. Error codes and Git validation remain unchanged.

User Impact

Operators see the actual cause and a recovery action. Non-Git folders, mismatched origins, wrong worktree ownership, and unavailable metadata retain distinct errors.

Evidence

Real Gateway WebSocket sessions.create proof used task-owned Git repositories:

Scenario Before After
Initialized repository without commits False not a git checkout message git checkout has no commits; create an initial commit and retry
Deferred first-turn preparation Same false checkout message Same specific cause and recovery hint
Origin mismatch or wrong worktree owner Generic checkout message Distinct repository error
Non-Git folder or unavailable metadata Existing specific failure path Existing code and recovery behavior preserved
Initial commit, then retry Normal creation Normal creation with the committed file and branch

Rejected synchronous requests created no session, branch, or managed worktree. Restoring the original Git metadata allowed normal reuse after the ownership controls. No model or provider call was needed.

The existing real-Git regression test requires both cause and recovery. Pinned formatting, independent source review, and CI run 34082629999 passed. Runtime proof used the run's compiled merge of this exact repair with its base; build identities are retained with the evidence.

Original diagnostic-propagation fix by @SunnyShu0925. AI-assisted repair and verification.

… collapsing them

session-worktree-preparation.ts replaced WorktreeRepositoryError messages
with a fixed "agent workspace is not a git checkout" string, hiding the
actual cause (e.g. missing commits, mismatched origin). Use
formatErrorMessage(error) so the thrown message reaches the operator.

Closes openclaw#140204
@clawsweeper

clawsweeper Bot commented Sep 6, 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 gateway Gateway runtime size: XS labels Sep 6, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 7, 2026, 12:36 AM ET / 04:36 UTC.

ClawSweeper review

What this changes

Preserve specific worktree session-creation errors, explain how to recover from a repository without commits, and update the regression assertion and troubleshooting documentation.

Merge readiness

✅ Ready for maintainer review

This PR remains necessary: current main still replaces the actionable repository error with a misleading checkout message. The focused repair and reported real Gateway verification support merging, with no blocking findings.

Priority: P2
Reviewed head: a2e7235b8bd19e4fd31ef58091ed67b94a4bc85a

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with useful real Gateway observations, an updated regression, and no blocking findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The captured PR body reports real Gateway WebSocket results exercising the changed shared preparation path: synchronous and deferred failures show the precise cause and recovery hint, while committing and retrying succeeds; sibling ownership and metadata cases retain their rejection behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured PR body reports real Gateway WebSocket results exercising the changed shared preparation path: synchronous and deferred failures show the precise cause and recovery hint, while committing and retrying succeeds; sibling ownership and metadata cases retain their rejection behavior.
Evidence reviewed 9 items Current main still contains the defect: The fetched main revision still substitutes the generic checkout message for every WorktreeRepositoryError in shared session preparation.
Introduced change verified: The local merge-base-to-head diff matches the supplied introduction evidence. It changes diagnostics, an existing regression assertion, and troubleshooting prose; validation, error codes, authority checks, and persistence remain unchanged. The diff whitespace check passed.
Repository-owned diagnosis and regression coverage: The repository service checks HEAD^{commit} and supplies the missing-commit recovery hint. The existing regression initializes a real Git repository without committing, then requires INVALID_REQUEST with both the precise cause and recovery instruction.
Findings None None.
Security None None.

How this fits together

Managed worktrees give OpenClaw sessions isolated Git branches and checkouts. Gateway session creation validates the source repository through shared preparation code, which returns either a prepared checkout or an operator-facing error.

flowchart TD
  A[Session creation request] --> B[Shared worktree preparation]
  B --> C[Validate source repository]
  C --> D{Valid committed checkout?}
  D -->|Yes| E[Prepare session worktree]
  D -->|No| F[Specific error and recovery guidance]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source 0, Tests +1, Docs +2. Total +3 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 4 4 0
Tests 1 2 1 +1
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 8 5 +3

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #140204
Summary: This PR is the explicit candidate fix for the linked diagnostic bug; the issue should remain open until the fix lands.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep repository validation authoritative and carry its redacted, actionable diagnosis through both synchronous and deferred session creation.

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

Yes: an initialized repository without HEAD reaches the specific repository error, which current main replaces with the wrong message. Source and the existing real-Git regression establish the path; this read-only review did not run it.

Is this the best way to solve the issue?

Yes: forwarding the existing diagnosis fixes all affected callers at their shared boundary without duplicating validation or changing accepted repositories.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 6223cf8b7480.

Labels

Label justifications:

  • P2: This fixes misleading recovery guidance for the bounded case of worktree creation from a repository without commits.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured PR body reports real Gateway WebSocket results exercising the changed shared preparation path: synchronous and deferred failures show the precise cause and recovery hint, while committing and retrying succeeds; sibling ownership and metadata cases retain their rejection behavior.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured PR body reports real Gateway WebSocket results exercising the changed shared preparation path: synchronous and deferred failures show the precise cause and recovery hint, while committing and retrying succeeds; sibling ownership and metadata cases retain their rejection behavior.

Evidence

What I checked:

  • Current main still contains the defect: The fetched main revision still substitutes the generic checkout message for every WorktreeRepositoryError in shared session preparation. (src/gateway/session-worktree-preparation.ts:161, 6223cf8b7480)
  • Introduced change verified: The local merge-base-to-head diff matches the supplied introduction evidence. It changes diagnostics, an existing regression assertion, and troubleshooting prose; validation, error codes, authority checks, and persistence remain unchanged. The diff whitespace check passed. (src/gateway/session-worktree-preparation.ts:161, a2e7235b8bd1)
  • Repository-owned diagnosis and regression coverage: The repository service checks HEAD^{commit} and supplies the missing-commit recovery hint. The existing regression initializes a real Git repository without committing, then requires INVALID_REQUEST with both the precise cause and recovery instruction. (src/gateway/server.sessions.create.test.ts:3945, a2e7235b8bd1)
  • Synchronous and deferred callers share the repair: Synchronous sessions.create calls shared preparation; deferred project preparation also calls it and forwards its returned message. The separate non-Git preflight remains intact, so its existing generic checkout assertions remain appropriate. (src/gateway/server-methods/session-create-project.ts:312, a2e7235b8bd1)
  • Captured real behavior evidence: The supplied complete PR body, captured under sourceRevision 5c2737913584732b4a403d01ee8117916f0aab7d6bbaaf866d6547eb9fc2ee6d, reports real Gateway WebSocket sessions.create observations using task-owned repositories and a compiled merge containing this repair. It records corrected synchronous and deferred errors, distinct origin/ownership failures, unchanged metadata recovery, successful creation after committing, and no session/branch/worktree creation for rejected synchronous requests. CI run https://github.com/openclaw/openclaw/actions/runs/34082629999 is supplemental; this review did not independently execute the runtime. (a2e7235b8bd1)
  • Linked report and review continuity: Worktree session creation reports "not a git checkout" when the repo has no commits #140204 documents the same incorrect diagnostic on an official installation and is explicitly paired with this open fix. The supplied previous review covered the same head and retained no findings or concrete rank-up moves; the captured timeline also records active assignment to obviyus.

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-06T16:05:20.991Z sha a4168e5 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-06T16:16:15.349Z sha a4168e5 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-07T04:25:38.725Z sha a2e7235 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 6, 2026
@obviyus obviyus self-assigned this Sep 7, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling labels Sep 7, 2026
@obviyus obviyus changed the title fix(gateway): propagate worktree repository error messages instead of collapsing them fix(worktrees): explain session creation failures for repositories without commits Sep 7, 2026
@obviyus
obviyus merged commit abd2d6f into openclaw:main Sep 7, 2026
219 checks passed
@obviyus

obviyus commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Thanks @SunnyShu0925!

Proof: Real Gateway WebSocket checks verified missing-commit diagnostics, initial-commit recovery, synchronous and deferred preparation, rejected-request state, distinct repository errors, and normal worktree creation. Independent behavior validation and source review cover the full acceptance contract. CI passed.

  • Bug: An initialized repository with no commits was incorrectly reported as not being a Git checkout.
  • Fix: Preserve the service-owned error and tell the operator to create an initial commit and retry.
Before After
agent workspace is not a git checkout git checkout has no commits; create an initial commit, then retry
Origin and ownership errors collapsed to the same message Distinct errors remain visible

Merged as abd2d6f. No CI exception was needed.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 8, 2026
…thout commits (openclaw#140251)

Preserve specific repository errors during session worktree preparation and tell operators to create an initial commit before retrying an empty repository.

Extend the existing regression assertion and document recovery. Real Gateway checks cover synchronous and deferred errors, rejected-request state, distinct repository failures, and successful committed-repository creation.

Closes openclaw#140204.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Worktree session creation reports "not a git checkout" when the repo has no commits

2 participants