siyuan-note/siyuan · error

parent path not found: %s

Error message

parent path not found: %s

What it means

Thrown by the `inbox convert` subcommand when the parent container derived from `--path` (hPath) does not resolve to an existing document root. The code calls `treenode.GetBlockTreeRootByHPath(notebook, parentDir)`; a nil result means no document with that human-readable path exists in the target notebook, so there is nowhere to place the converted shorthand(s).

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 251596fc0d)

Solutions

  1. Verify the parent document exists: `siyuan sql "select * from blocks where hpath='<parentDir>' and box='<notebook>'"`
  2. Create the parent document in the GUI or via `import`/`block` first, then re-run convert
  3. Omit `--path` (or pass `/`) to drop the shorthand at the notebook root

Example fix

// before
siyuan inbox convert --ids 1 --notebook 20240101 --path /Nonexistent/Parent
// after
# Create /Notes first, then:
siyuan inbox convert --ids 1 --notebook 20240101 --path /Notes
Defensive patterns

Strategy: validation

Validate before calling

// Verify the parent document exists in the target notebook before convert:
if parentDir != "/" {
    if bt := treenode.GetBlockTreeRootByHPath(notebook, parentDir); bt == nil {
        return fmt.Errorf("parent %q does not exist in notebook %s", parentDir, notebook)
    }
}

Prevention

When it happens

Trigger: Passing `--path /Notes/Sub` when no document named `Sub` exists under `/Notes` in the notebook; a typo in the hPath; targeting a notebook other than the one containing the parent. The check only runs when the parent dir is not `/` (root).

Common situations: Assuming the path is created on demand (it must already exist); mixing up notebook IDs; wrong hPath casing or separators; pointing at a leaf document instead of its container.

Related errors


AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12). Data as JSON: /api/errors/db772e1a879e4554. Report an issue: GitHub.