siyuan-note/siyuan · error

source document [ ] could not be read

Error message

source document [%s] could not be read

What it means

ReorderDocTree re-reads every source document from its parent directory listing after moving it out of any other parent context. If a source ID cannot be produced by that read (it is not a readable child where expected), the reorder is aborted, keeping current order and from-paths consistent.

Solutions

  1. Retry after the concurrent operation finishes; re-open/reindex the notebook
  2. Verify the .sy file exists at the block tree's recorded path on disk
  3. Rebuild the block tree index (rebuild index for the notebook) if paths are stale
  4. Re-issue the reorder with freshly fetched document IDs

Example fix

// before
await reorderDocs(sourceIDs, targetID, 'left')
// after
await refreshNotebookIndex(boxID)
const fresh = sourceIDs.filter(id => await docReadable(id))
if (fresh.length === sourceIDs.length) await reorderDocs(fresh, targetID, 'left')
Defensive patterns

Strategy: retry

Validate before calling

// confirm each source resolves right before the call
const allReadable = sourceIDs.every(id => listDocsUnderPath(path.dirname(getBlockTree(id).path)).some(d => d.id === id))

Try / catch

try { await reorderDocs(...) } catch (e) { if (/source document .* could not be read/.test(e)) { await waitIdle(); await reloadNotebook(boxID); await retryOnce() } }

Prevention

When it happens

Trigger: A source document passes the block-tree check but the actual directory listing cannot produce it — e.g. the .sy file was deleted between checks, the path is unreadable, or the source's parent path resolution (after detaching from a previous parent) fails.

Common situations: Concurrent modification: sync or another window deletes/renames the document while a reorder is in flight; external filesystem manipulation; corrupted .sy path in the block tree index.

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/e455b8e1cbfb90cd. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/file_tree_reorder.go:177

		if byID[id] != nil {
			continue
		}
		sourceParent := path.Dir(source.Path)
		if sourceParent != "/" {
			sourceParent += ".sy"
		}
		sourceDocs, _, loadErr := ListDocTree(source.BoxID, sourceParent, util.SortModeCustom, false, true, int(^uint(0)>>1))
		if loadErr != nil {
			return nil, loadErr
		}
		for _, doc := range sourceDocs {
			if doc.ID == id {
				byID[id] = doc
				break
			}
		}
		if byID[id] == nil {
			return nil, fmt.Errorf("source document [%s] could not be read", id)
		}
		currentIDs = append(currentIDs, id)
		fromPaths = append(fromPaths, source.Path)
	}
	orderedIDs, changed, err := reorderIDSequence(currentIDs, sourceIDs, targetID, position)
	if err != nil {
		return nil, err
	}
	ret = &DocTreeReorderResult{Changed: changed || len(fromPaths) > 0, Notebook: box.ID, ParentPath: listPath}
	for i := 1; i < len(orderedIDs); i++ {
		if fileTreeSortLess(byID[orderedIDs[i]], byID[orderedIDs[i-1]], mode) {
			ret.Conflict = true
			break
		}
	}
	if preview || !ret.Changed || ret.Conflict && !removeSorts {
		return ret, nil
	}

View on GitHub (pinned to 9f775e8a12)