siyuan-note/siyuan · error

parent path not found

Error message

parent path not found: %s

What it means

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.

Solutions

  1. Create the parent document(s) in the notebook first (e.g. via the UI or /api/filetree/createDocWithMd), then rerun the convert.
  2. Simplify `--path` to an existing parent, or omit `--path` / use `/` to land in the notebook root.
  3. Fix typos and case in the parent path; verify the exact document path exists.
  4. Ensure the notebook is open/indexed so the block tree contains the parent document.

Example fix

// before
siyuan inbox convert --ids abc --notebook NB --path /notes/inbox/2024
// after (parent /notes/inbox does not exist)
siyuan inbox convert --ids abc --notebook NB --path /notes
Defensive patterns

Strategy: validation

Validate before calling

# ensure parent doc exists first, or fall back to notebook root
if ! kernel_has_doc "$NOTEBOOK" "$(dirname "$HPATH")"; then HPATH="/"; fi
siyuan inbox convert --ids "$IDS" --notebook "$NOTEBOOK" --path "$HPATH"

Try / catch

err := cmd.Run()
if err != nil && strings.HasPrefix(err.Error(), "parent path not found") {
    // recreate parent doc or retry with --path /
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/db772e1a879e4554. Report an issue: GitHub.

Appendix: source

Thrown at kernel/cli/cmd/inbox.go:151

		ids := parseShorthandIDs(idsRaw)
		if len(ids) == 0 {
			return fmt.Errorf("--ids is required (comma-separated shorthand IDs)")
		}

		hPath, _ := cmd.Flags().GetString("path")
		if hPath == "" {
			hPath = "/"
		}
		removeAfter, _ := cmd.Flags().GetBool("remove-after")

		// 解析目标父路径(hPath→fsPath):hPath 指向新文档将要落入的父容器,
		// 其父目录必须已存在;不传或传 "/" 时落到笔记本根目录。
		parentPath := "/"
		parentDir := parentDir(hPath)
		if parentDir != "/" {
			bt := treenode.GetBlockTreeRootByHPath(notebook, parentDir)
			if bt == nil {
				return fmt.Errorf("parent path not found: %s", parentDir)
			}
			parentPath = strings.TrimSuffix(bt.Path, ".sy")
		}

		if dryRun {
			fmt.Printf("[dry-run] Would convert %d shorthand(s) -> notebook %s (hPath: %s, removeAfter: %v)\n",
				len(ids), notebook, hPath, removeAfter)
			for _, id := range ids {
				fmt.Printf("[dry-run]   - %s\n", id)
			}
			return nil
		}

		type result struct {
			ID     string `json:"id"`
			Title  string `json:"title"`
			DocID  string `json:"docId"`
			Status string `json:"status"`

View on GitHub (pinned to 9f775e8a12)