siyuan-note/siyuan · warning

hpath refresh document is not indexed

Error message

hpath refresh document is not indexed

What it means

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.

Solutions

  1. Wait for indexing to complete and let the task retry (the task is retained, not dropped)
  2. Trigger a manual index rebuild for the notebook (rebuild index on the notebook) to restore the block-tree entry
  3. Check the stat error branch: if the message comes with another error, fix that underlying filesystem problem
  4. Verify the .sy file exists at the expected path; if it is a stray file, remove it so the task can be completed
Defensive patterns

Strategy: retry

Try / catch

ok, err := task.refresh(); if err != nil && err.Error() == "hpath refresh document is not indexed" { // task is retained; rerun RefreshHPathsJob after indexing completes }

Prevention

When it happens

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

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

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at kernel/model/hpath_refresh.go:413

		}
	}
}

func refreshHPathsTask(task *hpathRefreshTask) (done bool, err error) {
	if task.started.IsZero() {
		task.started = time.Now()
	}
	root := treenode.GetBlockTreeInBox(task.ID, task.Box)
	if !IsEncryptedBox(task.Box) && (root == nil || root.BoxID != task.Box) {
		root = treenode.GetBlockTree(task.ID)
		if root != nil && IsEncryptedBox(root.BoxID) {
			return false, errors.New("hpath refresh crossed an encrypted notebook boundary")
		}
	}
	if root == nil {
		// 索引尚未恢复时不能丢弃磁盘上仍存在的文档任务。
		if _, statErr := os.Stat(filepath.Join(util.DataDir, task.Box, task.Path)); statErr == nil {
			return false, errors.New("hpath refresh document is not indexed")
		} else if !os.IsNotExist(statErr) {
			return false, statErr
		}
		return true, nil
	}
	scope := sha256.Sum256([]byte(root.BoxID + "\x00" + root.Path + "\x00" + root.HPath))
	if task.scope != scope {
		task.docs, task.index, task.covers = nil, 0, nil
		task.blockAfter, task.treeAfter = 0, 0
		task.scope = scope
	}
	if task.docs == nil {
		if task.recover {
			hpath, properties, loadErr := filesys.ReadDocHPath(root.BoxID, root.Path)
			if loadErr != nil {
				return false, loadErr
			}
			tree := treenode.NewTree(root.BoxID, root.Path, hpath, properties["title"])

View on GitHub (pinned to 9f775e8a12)