Skip to content

fix(templates): Template Add fails when the state dir path contains a symlink - #198520

Merged
Patrick-Erichsen merged 1 commit into
openclaw:mainfrom
etzelm:fix/templates-admitted-workspace-realpath
Nov 15, 2026
Merged

Patrick-Erichsen merged 1 commit into
openclaw:mainfrom
etzelm:fix/templates-admitted-workspace-realpath

Conversation

@etzelm

@etzelm etzelm commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: every Gateway Template Add ends partial with template_initialization_failed when OPENCLAW_STATE_DIR sits under a symlinked path.

User Impact

User impact: Templates Add and open normally on hosts where the state dir is reached through a symlink (for example a home folder linked to an external volume). Before, the new agent and chat were kept but the Template's workspace files were never written.

Why This Change Was Made

Gateway Add first admits the agent and its workspace, then replans with that admitted workspace. The planner compared the realpath of the target workspace with the raw admitted path, so under a symlink the two differed and the planner reported a workspace collision against the workspace it had just created. The admitted path now goes through the same canonicalizer before the comparison. Identical inputs still compare equal.

Evidence

  • New test in src/templates/gateway-add-plan.test.ts symlinks a temp state dir, points OPENCLAW_STATE_DIR at the link and asserts no workspace_collision. It fails on origin/main and passes with the fix.
  • pnpm exec vitest run src/templates/gateway-add-plan.test.ts src/templates/gateway-add-apply.test.ts: pass.
  • pnpm check:changed --base origin/main: everything passes except the dead export scan, which fails the same way on origin/main in files this PR does not touch.
  • Live run, isolated Gateway built from this branch stack, state dir ~/work/.../home/.openclaw where ~/work is a symlink to an external volume:
before: templates add myfitnessclaw
{"agentId":"myfitnessclaw-2","status":"partial","error":{"code":"template_initialization_failed","message":"The Template changed since review. Preview it again. ..."}}
after:  templates add myfitnessclaw
{"agentId":"myfitnessclaw-2","status":"complete","error":null}
workspace-myfitnessclaw-2: AGENTS.md IDENTITY.md SOUL.md avatars reference skills templates
first message reply arrived 31 s after Add started

Found during a sweep that Added all 28 third-party ClawHub Templates on an isolated Gateway.

… dir

- The Add planner canonicalizes the target workspace through realpath but compared it with the raw admitted workspace path.
- With OPENCLAW_STATE_DIR under a symlink the planner reported workspace_collision for the workspace admission had just created, so every Gateway Add ended partial with template_initialization_failed and the new session stayed initializing.
- Canonicalize the admitted workspace before the comparison.
@clawsweeper

clawsweeper Bot commented Nov 14, 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.

@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. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 14, 2026
@clawsweeper

clawsweeper Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Canonicalizes the admitted workspace path before comparing it with the planned workspace.

Example: OPENCLAW_STATE_DIR uses /home/alex/work/.openclaw, where /home/alex/work links to /Volumes/data/work.

  • Before: Template Add incorrectly treats its newly admitted workspace as a collision and returns template_initialization_failed.
  • After: Both workspace paths resolve to the same location, allowing initialization to complete.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-supported repair with a distinct filesystem regression and relevant live Gateway evidence; hosted CI remains gated before execution.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied isolated-Gateway output exercises Template Add with a symlinked state-directory ancestor and records successful completion, installed workspace files, and a first model reply after the fix.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Template Add retains a new agent and chat but fails to initialize them when the state-directory path contains a symlink.
Reason: The change restores the existing admitted-workspace contract without adding options, changing defaults, or introducing another owner.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR fixes a current Template Add failure with a focused change and relevant live evidence; no correctness findings remain, but required CI has not run.

Priority: P1
Reviewed head: 7f6ec93cb4e408715b966f29d0de64677d97e6a7

Before merge

Findings

None.

Agent review details

How this fits together

The Template planner receives a verified package and Gateway creation context, then produces workspace actions and blockers for the existing installer.

flowchart TD
A[Template Add request] --> B[Gateway agent admission]
B --> C[Template planner]
D[Existing path canonicalizer] --> C
C --> E[Workspace collision decision]
E --> F[Existing Template installer]
F --> G[Initialized agent chat]
Loading

Technical review

Best possible solution:

Merge this focused canonicalization fix once the required checks complete successfully.

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

Current-main source establishes the raw-versus-canonical comparison, and the contributor supplies matching before/after Gateway output; no target code was executed during this read-only review.

Is this the best way to solve the issue?

This is the smallest complete fix: compare both identities through the existing canonicalizer while preserving collision and installer ownership checks.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 9156de83fa53.

Provenance checked

  • Admitted workspace collision exception keeps the original intent (caa978c: Create the ordinary agent and durable chat before remote Template setup, then initialize that exact admitted workspace.)
  • Canonical workspace identity keeps the original intent (88a7306: Use canonical workspace identity for consented agent creation and collision handling.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +3, Tests +19. Total +22 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 5 2 +3
Tests 1 20 1 +19
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 25 3 +22

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:

No label changes.

Label justifications:

  • P1: The current mismatch prevents Template agents from initializing on hosts with symlinked state-directory paths.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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.

Reviewed November 13, 2026, 7:51 PM ET / November 14, 2026, 00:51 UTC.

@roboclaw-bot roboclaw-bot added the clawtributors PR from a clawtributor label Nov 14, 2026
@Patrick-Erichsen
Patrick-Erichsen merged commit a1dd493 into openclaw:main Nov 15, 2026
132 checks passed
@Patrick-Erichsen

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 16, 2026
… dir (openclaw#198520)

- The Add planner canonicalizes the target workspace through realpath but compared it with the raw admitted workspace path.
- With OPENCLAW_STATE_DIR under a symlink the planner reported workspace_collision for the workspace admission had just created, so every Gateway Add ended partial with template_initialization_failed and the new session stayed initializing.
- Canonicalize the admitted workspace before the comparison.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawtributors PR from a clawtributor P1 High-priority user-facing bug, regression, or broken workflow. 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