{"record":{"id":"db772e1a879e4554","repo":"siyuan-note/siyuan","slug":"parent-path-not-found-s","errorCode":null,"errorMessage":"parent path not found: %s","messagePattern":"parent path not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/inbox.go","lineNumber":151,"sourceCode":"\t\tids := parseShorthandIDs(idsRaw)\n\t\tif len(ids) == 0 {\n\t\t\treturn fmt.Errorf(\"--ids is required (comma-separated shorthand IDs)\")\n\t\t}\n\n\t\thPath, _ := cmd.Flags().GetString(\"path\")\n\t\tif hPath == \"\" {\n\t\t\thPath = \"/\"\n\t\t}\n\t\tremoveAfter, _ := cmd.Flags().GetBool(\"remove-after\")\n\n\t\t// 解析目标父路径（hPath→fsPath）：hPath 指向新文档将要落入的父容器，\n\t\t// 其父目录必须已存在；不传或传 \"/\" 时落到笔记本根目录。\n\t\tparentPath := \"/\"\n\t\tparentDir := parentDir(hPath)\n\t\tif parentDir != \"/\" {\n\t\t\tbt := treenode.GetBlockTreeRootByHPath(notebook, parentDir)\n\t\t\tif bt == nil {\n\t\t\t\treturn fmt.Errorf(\"parent path not found: %s\", parentDir)\n\t\t\t}\n\t\t\tparentPath = strings.TrimSuffix(bt.Path, \".sy\")\n\t\t}\n\n\t\tif dryRun {\n\t\t\tfmt.Printf(\"[dry-run] Would convert %d shorthand(s) -> notebook %s (hPath: %s, removeAfter: %v)\\n\",\n\t\t\t\tlen(ids), notebook, hPath, removeAfter)\n\t\t\tfor _, id := range ids {\n\t\t\t\tfmt.Printf(\"[dry-run]   - %s\\n\", id)\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\n\t\ttype result struct {\n\t\t\tID     string `json:\"id\"`\n\t\t\tTitle  string `json:\"title\"`\n\t\t\tDocID  string `json:\"docId\"`\n\t\t\tStatus string `json:\"status\"`","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/cli/cmd/inbox.go#L133-L169","documentation":"When converting inbox shorthands, the parent directory of the target `--path` must already exist as a document in the notebook. The command looks up the parent HPath with treenode.GetBlockTreeBlockByHPath; if no indexed document tree root exists for that path, it refuses rather than creating intermediate documents.","triggerScenarios":"Running `inbox convert ... --path /a/b/doc` where document `/a/b` does not exist in the notebook; or `--path /x/y` where `/x` was never created. Only non-root parents are checked.","commonSituations":"Typing the target path by hand with a typo; the notebook was never opened/indexed so the block tree has no record; the parent document was renamed or deleted after composing the command; case-sensitivity mismatch in the path.","solutions":["Create the parent document(s) in the notebook first (e.g. via the UI or /api/filetree/createDocWithMd), then rerun the convert.","Simplify `--path` to an existing parent, or omit `--path` / use `/` to land in the notebook root.","Fix typos and case in the parent path; verify the exact document path exists.","Ensure the notebook is open/indexed so the block tree contains the parent document."],"exampleFix":"// before\nsiyuan inbox convert --ids abc --notebook NB --path /notes/inbox/2024\n// after (parent /notes/inbox does not exist)\nsiyuan inbox convert --ids abc --notebook NB --path /notes","handlingStrategy":"validation","validationCode":"# ensure parent doc exists first, or fall back to notebook root\nif ! kernel_has_doc \"$NOTEBOOK\" \"$(dirname \"$HPATH\")\"; then HPATH=\"/\"; fi\nsiyuan inbox convert --ids \"$IDS\" --notebook \"$NOTEBOOK\" --path \"$HPATH\"","typeGuard":null,"tryCatchPattern":"err := cmd.Run()\nif err != nil && strings.HasPrefix(err.Error(), \"parent path not found\") {\n    // recreate parent doc or retry with --path /\n}","preventionTips":["Create the full parent document path before converting","Prefer omitting --path (defaults to notebook root) when unsure","Match path case and spelling exactly to existing documents","Keep the target notebook open so the block tree is populated"],"tags":["cli","path","document-not-found"],"backgroundTag":"directory-not-found","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"}