{"record":{"id":"5045faeefb6849a0","repo":"siyuan-note/siyuan","slug":"failed-to-make-directory-w","errorCode":null,"errorMessage":"failed to make directory: %w","messagePattern":"failed to make directory: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/plugin/api_storage.go","lineNumber":278,"sourceCode":"\t\t\t\t\t\terr = fmt.Errorf(\"panic during siyuan.storage.put: %v\", r)\n\t\t\t\t\t}\n\n\t\t\t\t\tp.worker.Run(func(rt *goja.Runtime) (_ any, _ error) {\n\t\t\t\t\t\tif lo.IsNil(err) {\n\t\t\t\t\t\t\tif resolveErr := resolve(result); resolveErr != nil {\n\t\t\t\t\t\t\t\tlogging.LogErrorf(\"[plugin:%s] siyuan.storage.put resolve: %v\", p.Name, resolveErr)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif rejectErr := reject(rt.NewGoError(err)); rejectErr != nil {\n\t\t\t\t\t\t\t\tlogging.LogErrorf(\"[plugin:%s] siyuan.storage.put reject: %v\", p.Name, rejectErr)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn\n\t\t\t\t\t}, nil)\n\t\t\t\t}()\n\n\t\t\t\tif mkdirErr := os.MkdirAll(filepath.Dir(abs), 0755); mkdirErr != nil {\n\t\t\t\t\terr = fmt.Errorf(\"failed to make directory: %w\", mkdirErr)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif writeErr := filelock.WriteFile(abs, []byte(content)); writeErr != nil {\n\t\t\t\t\terr = fmt.Errorf(\"failed to write file: %w\", writeErr)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}()\n\n\t\t\treturn\n\t\t}, func(rt *goja.Runtime, result any, err error) {\n\t\t\tif !lo.IsNil(err) {\n\t\t\t\tif rejectErr := reject(rt.NewGoError(err)); rejectErr != nil {\n\t\t\t\t\tlogging.LogErrorf(\"[plugin:%s] siyuan.storage.put reject: %v\", p.Name, rejectErr)\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t\tif runErr != nil {","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/plugin/api_storage.go#L260-L296","documentation":"os.MkdirAll failed when siyuan.storage.put tried to create the parent directories of the target file inside the plugin's storage directory (mode 0755). The wrapped OS error (%w) explains the cause — most often a permission problem, an existing non-directory file at a path component, or an invalid/over-long path.","triggerScenarios":"A parent path component exists as a regular file (e.g. \"data\" is a file, so \"data/x.json\" cannot be created); the storage directory or a parent is read-only on disk; the workspace volume is full or the path exceeds NAME_MAX/MAX_PATH limits.","commonSituations":"Plugins writing to nested paths like \"cache/http/resp.json\" where a previous version stored a file at \"cache\"; running SiYuan from a location without write permissions; sync tools replacing directories with files.","solutions":["Read the wrapped OS error in the rejection to identify the failing component","Check that no file exists at any parent segment of the target path; remove or rename it (via siyuan.storage.remove or the filesystem)","Verify the workspace directory and plugin storage dir are writable by the kernel process","Shorten the path if it may exceed filesystem name/length limits"],"exampleFix":"// before\nawait siyuan.storage.put(\"data/config/app.json\", s); // \"data/config\" exists as a FILE\n// after\nawait siyuan.storage.remove(\"data/config\").catch(() => {}); // clear conflicting file\nawait siyuan.storage.put(\"data/config/app.json\", s);","handlingStrategy":"try-catch","validationCode":"// ensure no parent segment is used as both file and directory\nif (usedAsFile.has(parentDir)) throw new Error(`\"${parentDir}\" is already a file`);","typeGuard":"null","tryCatchPattern":"try { await siyuan.storage.put(path, content); } catch (e) { if (String(e.message).includes(\"failed to make directory\")) console.error(\"mkdir failed:\", e.message); throw e; }","preventionTips":["Never reuse the same relative path as both a file and a directory prefix","Keep storage paths short and shallow to dodge length limits","Confirm the workspace volume is writable and not full before nested writes","Avoid paths whose parent segments depend on user input that could collide"],"tags":["plugins","filesystem","mkdir","permissions","siyuan"],"backgroundTag":"mkdir-permission-denied","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}