{"record":{"id":"28249530378304bf","repo":"multica-ai/multica","slug":"create-s-directory-s-w","errorCode":null,"errorMessage":"create %s directory %s: %w","messagePattern":"create (.+?) directory (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/internal/daemon/execenv/codex_home.go","lineNumber":1019,"sourceCode":"// daemon's mkdir, remove, or write outside it.\n//\n// This matters because a task home is reused: a prepare can run against a\n// directory a previous task already wrote to. Without the root, a task that\n// replaced an intermediate directory of its own home with a link to somewhere\n// else would have the daemon delete and overwrite the link target on the next\n// prepare. os.Root still allows links that stay inside the task home, which is\n// harmless, and rejects the ones that leave it. The root itself is\n// identity-checked by openVerifiedCodexHomeRoot.\nfunc materialiseInCodexHome(codexHome, relPath, src, key string) error {\n\troot, err := openVerifiedCodexHomeRoot(codexHome, key)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer root.Close()\n\n\tif dir := filepath.Dir(relPath); dir != \".\" {\n\t\tif err := root.MkdirAll(dir, 0o755); err != nil {\n\t\t\treturn fmt.Errorf(\"create %s directory %s: %w\", key, dir, err)\n\t\t}\n\t}\n\tif _, err := root.Lstat(relPath); err == nil {\n\t\tif err := root.Remove(relPath); err != nil {\n\t\t\treturn fmt.Errorf(\"remove stale %s copy %s: %w\", key, relPath, err)\n\t\t}\n\t} else if !os.IsNotExist(err) {\n\t\treturn fmt.Errorf(\"stat %s copy %s: %w\", key, relPath, err)\n\t}\n\n\tin, err := os.Open(src)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"open %s %s: %w\", key, src, err)\n\t}\n\tdefer in.Close()\n\n\tout, err := root.OpenFile(relPath, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0o644)\n\tif err != nil {","sourceCodeStart":1001,"sourceCodeEnd":1037,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/internal/daemon/execenv/codex_home.go#L1001-L1037","documentation":"materialiseInCodexHome calls root.MkdirAll for the parent directories of the destination (e.g. the parent of a config file copy) inside the verified os.Root. Failure means the intermediate directory could not be created: a non-directory file exists in the way, permissions, or a symlink leaves the root (os.Root rejects links that escape the task home).","triggerScenarios":"A previous task left a regular file where a directory is needed; a symlinked intermediate directory points outside the task home; read-only filesystem.","commonSituations":"Reused task home polluted by earlier task output; a task linked an intermediate dir to /tmp or another task's area.","solutions":["Inspect the offending intermediate path under the task home and remove the blocking file or escaping symlink","Reset/recreate the task home if its contents are untrusted","Check filesystem write permissions for the daemon user"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"dir := filepath.Join(codexHome, filepath.Dir(relPath))\nif fi, err := os.Lstat(dir); err == nil && !fi.IsDir() {\n\treturn fmt.Errorf(\"blocked path %s is not a directory\", dir)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Reset task homes between untrusted tasks","Ensure no escaping symlinks exist on config subpaths before prepare"],"tags":["filesystem","codex-home","symlink","sandbox-escape"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}