{"record":{"id":"d385b461c967f8e3","repo":"siyuan-note/siyuan","slug":"target-human-readable-path-not-found-s","errorCode":null,"errorMessage":"target human-readable path not found: %s","messagePattern":"target human-readable path not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/document.go","lineNumber":324,"sourceCode":"\t})\n}\n\nfunc resolvePathWithLookup(userPath, hpath string, lookup func(string) (string, bool)) (string, error) {\n\tif \"\" != userPath {\n\t\treturn userPath, nil\n\t}\n\tif \"\" == hpath {\n\t\treturn \"/\", nil\n\t}\n\n\ttargetHPath := path.Clean(\"/\" + strings.TrimPrefix(hpath, \"/\"))\n\tif \"/\" == targetHPath {\n\t\treturn \"/\", nil\n\t}\n\tif targetPath, found := lookup(targetHPath); found {\n\t\treturn targetPath, nil\n\t}\n\treturn \"\", fmt.Errorf(\"target human-readable path not found: %s\", targetHPath)\n}\n\nfunc resolveDocumentMovePath(boxID, userPath, hpath, sourceHPath string) (string, error) {\n\treturn resolveDocumentMovePathWithLookup(userPath, hpath, sourceHPath, func(targetHPath string) (string, bool) {\n\t\tbt := treenode.GetBlockTreeRootByHPath(boxID, targetHPath)\n\t\tif nil == bt {\n\t\t\treturn \"\", false\n\t\t}\n\t\treturn bt.Path, true\n\t})\n}\n\nfunc resolveDocumentMovePathWithLookup(\n\tuserPath, hpath, sourceHPath string,\n\tlookup func(string) (string, bool),\n) (string, error) {\n\tif \"\" != userPath {\n\t\treturn userPath, nil","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/cli/cmd/document.go#L306-L342","documentation":"resolvePathWithLookup maps a target human-readable path (hpath like \"/foo/bar\") to an internal path. If the path is not the root \"/\" and the supplied lookup callback cannot find a block-tree root for it, the resolver returns this error. It means the destination path does not correspond to any existing document hierarchy node in the given notebook.","triggerScenarios":"Moving a document with `document move --hpath /Some/Missing/Path` where no document exists at that path in the destination notebook; typos in the hpath; hpath given with a trailing slash or wrong letter case; moving into a notebook whose index has not been built.","commonSituations":"Scripts hardcoding destination paths that were renamed or deleted; cross-notebook moves where the path exists in the source notebook but not the target; workspaces where the target notebook is new and not yet indexed.","solutions":["Verify the exact hpath exists in the destination notebook (check in the SiYuan UI or via document search) and correct spelling/case","Omit --hpath or use \"/\" to move to the notebook root, which is always valid","Ensure the destination notebook is open/indexed so its block tree is available; open it once in the UI if needed","Create the parent documents at the target path before moving"],"exampleFix":"// before\ndocument move --id \"$ID\" --notebook \"$BOX\" --hpath \"/Archive/Old Notes\"  // path may not exist\n// after\nif ! siyuan document search \"Old Notes\" | grep -q Archive; then\n  echo \"target hpath does not exist; falling back to root\"\nfi\ndocument move --id \"$ID\" --notebook \"$BOX\" --hpath \"/Archive/Old Notes\"","handlingStrategy":"validation","validationCode":"// Pre-check that the target hpath exists before moving\nconst exists = siyuanDocSearch(targetHPath.split(\"/\").pop()) !== null;\nif (!exists) {\n  throw new Error(`Refusing to move: ${targetHPath} not found in notebook ${boxID}`);\n}\nawait runCli(`document move --id ${docID} --notebook ${boxID} --hpath \"${targetHPath}\"`);","typeGuard":"function isNonEmptyHPath(p) {\n  return typeof p === \"string\" && p.startsWith(\"/\") && !p.endsWith(\"/\") && p.length > 1;\n}","tryCatchPattern":"try {\n  runCli(`document move --id ${id} --notebook ${box} --hpath \"${hpath}\"`);\n} catch (e) {\n  if (String(e).includes(\"target human-readable path not found\")) {\n    runCli(`document move --id ${id} --notebook ${box} --hpath \"/\"`); // fallback to root\n  } else {\n    throw e;\n  }\n}","preventionTips":["Verify destination hpaths exist in the target notebook before scripted moves","Normalize generated paths: trim trailing slashes and match case exactly","Open/index new notebooks once before moving documents into them","Fall back to the notebook root (\"/\") when an exact path cannot be resolved"],"tags":["cli","path-resolution","document-move"],"backgroundTag":"resource-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"}