{"record":{"id":"9586d48d59560cca","repo":"siyuan-note/siyuan","slug":"hpath-refresh-document-is-not-indexed","errorCode":null,"errorMessage":"hpath refresh document is not indexed","messagePattern":"hpath refresh document is not indexed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kernel/model/hpath_refresh.go","lineNumber":413,"sourceCode":"\t\t}\n\t}\n}\n\nfunc refreshHPathsTask(task *hpathRefreshTask) (done bool, err error) {\n\tif task.started.IsZero() {\n\t\ttask.started = time.Now()\n\t}\n\troot := treenode.GetBlockTreeInBox(task.ID, task.Box)\n\tif !IsEncryptedBox(task.Box) && (root == nil || root.BoxID != task.Box) {\n\t\troot = treenode.GetBlockTree(task.ID)\n\t\tif root != nil && IsEncryptedBox(root.BoxID) {\n\t\t\treturn false, errors.New(\"hpath refresh crossed an encrypted notebook boundary\")\n\t\t}\n\t}\n\tif root == nil {\n\t\t// 索引尚未恢复时不能丢弃磁盘上仍存在的文档任务。\n\t\tif _, statErr := os.Stat(filepath.Join(util.DataDir, task.Box, task.Path)); statErr == nil {\n\t\t\treturn false, errors.New(\"hpath refresh document is not indexed\")\n\t\t} else if !os.IsNotExist(statErr) {\n\t\t\treturn false, statErr\n\t\t}\n\t\treturn true, nil\n\t}\n\tscope := sha256.Sum256([]byte(root.BoxID + \"\\x00\" + root.Path + \"\\x00\" + root.HPath))\n\tif task.scope != scope {\n\t\ttask.docs, task.index, task.covers = nil, 0, nil\n\t\ttask.blockAfter, task.treeAfter = 0, 0\n\t\ttask.scope = scope\n\t}\n\tif task.docs == nil {\n\t\tif task.recover {\n\t\t\thpath, properties, loadErr := filesys.ReadDocHPath(root.BoxID, root.Path)\n\t\t\tif loadErr != nil {\n\t\t\t\treturn false, loadErr\n\t\t\t}\n\t\t\ttree := treenode.NewTree(root.BoxID, root.Path, hpath, properties[\"title\"])","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/hpath_refresh.go#L395-L431","documentation":"When the block tree has no record for the hpath refresh task's document, the task cannot be applied yet. The code checks the filesystem: if the .sy file still exists on disk it reports 'not indexed' and keeps the task for retry; if the file is gone the task is completed (document was deleted); other stat errors are propagated.","triggerScenarios":"refreshHPathsTask runs while the document's block-tree entry is missing (root == nil) but the file at data/<box>/<task.Path> still exists — i.e. the index has not caught up with the document yet.","commonSituations":"Immediately after workspace restore/sync where indexing is still running; after a crashed index rebuild; very large notebooks where the index queue lags behind the refresh job.","solutions":["Wait for indexing to complete and let the task retry (the task is retained, not dropped)","Trigger a manual index rebuild for the notebook (rebuild index on the notebook) to restore the block-tree entry","Check the stat error branch: if the message comes with another error, fix that underlying filesystem problem","Verify the .sy file exists at the expected path; if it is a stray file, remove it so the task can be completed"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"ok, err := task.refresh(); if err != nil && err.Error() == \"hpath refresh document is not indexed\" { // task is retained; rerun RefreshHPathsJob after indexing completes }","preventionTips":["Wait for initial indexing to finish before running background maintenance jobs","Trigger notebook index rebuild after restoring or syncing a workspace","Monitor index queue lag on very large notebooks"],"tags":["indexing","hpath","retry","consistency"],"backgroundTag":"record-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"}