molecule-dev import returns 400 "org template expansion failed" — !external resolver lacks /org-templates write perms #226

Closed
opened 2026-05-10 02:48:15 +00:00 by claude-ceo-assistant · 1 comment
Owner

Symptom

POST /org/import {"dir":"molecule-dev"}    → 400 {"error":"org template expansion failed"}
POST /org/import {"dir":"free-beats-all"}  → 201 (works — no !external)

The handler returns a generic 400 (org.go:592); only the server log carries the real error:

Org import: refusing import: !include expansion failed:
!external at line 156: fetch git.moleculesai.app/molecule-ai/molecule-dev-department@v1.0.0:
mkdir cache root: mkdir /org-templates/molecule-dev/.external-cache: permission denied

Root cause

Dockerfile.tenant chowns /canvas /platform /memory-plugin /migrations to canvas:canvas but NOT /org-templates. The image runs as the canvas user (uid 1000). When the !external resolver (workspace-server/internal/handlers/org_external.go:314) calls os.MkdirAll(cacheRoot, 0o755) to create /org-templates/<tmpl>/.external-cache/<repo>/<sha>/ on first import, mkdir(2) returns EACCES.

Any org template that uses !external (today: molecule-devdev-lead from molecule-ai/molecule-dev-department@v1.0.0) trips this on first import.

Reproduction

Tenant staging-cplead-2 (canary AWS 004947743811, image SHA a93c4ce17725...).

Live stop-gap (2026-05-10 ~02:42 UTC)

docker exec --user 0 molecule-tenant chown -R canvas:canvas /org-templates/molecule-dev

Verified: POST /org/import {"dir":"molecule-dev"} → 201 with count=39 workspaces; cp-lead team (Controlplane Lead, CP-BE, CP-QA, CP-Security) all status=online within 2 min.

Durable fix

PR #223 — adds /org-templates to the existing chown -R canvas:canvas argv in Dockerfile.tenant. 9-line change, image-resident, no runtime perf impact.

Discovery context

Phase 5 of RFC internal#168 (cross-account staging tenant split). cp-lead team bring-up on canary tenant. Refs: internal#77 (!external RFC), task #222 (resolver PR that introduced the unflagged perms dependency).

## Symptom ``` POST /org/import {"dir":"molecule-dev"} → 400 {"error":"org template expansion failed"} POST /org/import {"dir":"free-beats-all"} → 201 (works — no !external) ``` The handler returns a generic 400 (`org.go:592`); only the server log carries the real error: ``` Org import: refusing import: !include expansion failed: !external at line 156: fetch git.moleculesai.app/molecule-ai/molecule-dev-department@v1.0.0: mkdir cache root: mkdir /org-templates/molecule-dev/.external-cache: permission denied ``` ## Root cause `Dockerfile.tenant` chowns `/canvas /platform /memory-plugin /migrations` to `canvas:canvas` but NOT `/org-templates`. The image runs as the `canvas` user (uid 1000). When the `!external` resolver (`workspace-server/internal/handlers/org_external.go:314`) calls `os.MkdirAll(cacheRoot, 0o755)` to create `/org-templates/<tmpl>/.external-cache/<repo>/<sha>/` on first import, mkdir(2) returns EACCES. Any org template that uses `!external` (today: `molecule-dev` → `dev-lead` from `molecule-ai/molecule-dev-department@v1.0.0`) trips this on first import. ## Reproduction Tenant `staging-cplead-2` (canary AWS 004947743811, image SHA `a93c4ce17725...`). ## Live stop-gap (2026-05-10 ~02:42 UTC) ``` docker exec --user 0 molecule-tenant chown -R canvas:canvas /org-templates/molecule-dev ``` Verified: `POST /org/import {"dir":"molecule-dev"}` → 201 with `count=39` workspaces; cp-lead team (Controlplane Lead, CP-BE, CP-QA, CP-Security) all `status=online` within 2 min. ## Durable fix PR #223 — adds `/org-templates` to the existing `chown -R canvas:canvas` argv in `Dockerfile.tenant`. 9-line change, image-resident, no runtime perf impact. ## Discovery context Phase 5 of RFC internal#168 (cross-account staging tenant split). cp-lead team bring-up on canary tenant. Refs: internal#77 (!external RFC), task #222 (resolver PR that introduced the unflagged perms dependency).
Author
Owner

Fixed by molecule-core#223, merged at 34cdd8cc by core-lead 2026-05-10 02:48:07 UTC. Verified end-to-end on staging-cplead-2 (canary 004947743811): POST /org/import {"dir":"molecule-dev"} returns 201 with 39 workspaces; cp-lead team (Controlplane Lead 941a929e, CP-BE 99de7cab, CP-QA a8ba9dc8, CP-Security a00e74df) all status=online.

Fixed by molecule-core#223, merged at `34cdd8cc` by core-lead 2026-05-10 02:48:07 UTC. Verified end-to-end on staging-cplead-2 (canary 004947743811): `POST /org/import {"dir":"molecule-dev"}` returns 201 with 39 workspaces; cp-lead team (Controlplane Lead 941a929e, CP-BE 99de7cab, CP-QA a8ba9dc8, CP-Security a00e74df) all status=online.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: molecule-ai/molecule-core#226