Repository navigation
fix(templates): Template Add fails when the state dir path contains a symlink - #198520
Patrick-Erichsen merged 1 commit into
Conversation
… 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.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. What this changesCanonicalizes 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible 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 Before merge
FindingsNone. Agent review detailsHow this fits togetherThe 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]
Technical reviewBest 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
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +3, Tests +19. Total +22 across 2 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 13, 2026, 7:51 PM ET / November 14, 2026, 00:51 UTC. |
|
Merged via squash.
|
… 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.
What Problem This Solves
Fixes: every Gateway Template Add ends partial with
template_initialization_failedwhenOPENCLAW_STATE_DIRsits 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
src/templates/gateway-add-plan.test.tssymlinks a temp state dir, pointsOPENCLAW_STATE_DIRat the link and asserts noworkspace_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.~/work/.../home/.openclawwhere~/workis a symlink to an external volume:Found during a sweep that Added all 28 third-party ClawHub Templates on an isolated Gateway.