siyuan-note/siyuan · error

document [ ] could not be read

Error message

document [%s] could not be read

What it means

After loading the sibling custom order for the target's parent, ReorderDocTree cross-checks every ID present in the persisted order (sort.json) against the documents actually readable from disk (loadSiblingCustomOrder / ListDocsUnderPath). An ID in the saved order that no longer corresponds to a readable document aborts the reorder, keeping the sort file from silently corrupting the tree view.

Solutions

  1. Remove the stale ID entries from <data>/<boxID>/.siyuan/sort.json and retry
  2. Re-trigger the document reindex (reload notebooks) so disk and sort config agree
  3. Restore the deleted .sy file if the stale entry should still exist
  4. Delete sort.json to fall back to default ordering, then re-apply custom order

Example fix

// before (retry blindly)
reorderDocs(sources, target, 'left')
// after
const sorts = JSON.parse(await readSortJson(boxID))
for (const id of Object.keys(sorts)) if (!await docExists(id)) delete sorts[id]
await writeSortJson(boxID, sorts)
reorderDocs(sources, target, 'left')
Defensive patterns

Strategy: fallback

Validate before calling

// prune stale entries from sort.json before reordering
const sorts = readSortJson(boxID)
for (const id of Object.keys(sorts)) if (!docExistsOnDisk(boxID, id)) delete sorts[id]

Try / catch

try { await reorderDocs(...) } catch (e) { if (/could not be read/.test(e)) { cleanupSortJson(boxID); await retry() } }

Prevention

When it happens

Trigger: sort.json for the notebook contains an ID of a document that was deleted on disk (manually, by sync conflict resolution, or an interrupted delete) so byID lookup returns nil for a sibling ID.

Common situations: Manual editing or external deletion of .sy files; sync removed documents without updating the custom sort file; restoring an older sort.json against newer data.

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

Appendix: source

Thrown at kernel/model/file_tree_reorder.go:146

	}
	// 隐藏文档和超过显示上限的文档也必须参与排序。
	docs, _, err := ListDocTree(box.ID, listPath, mode, false, true, int(^uint(0)>>1))
	if err != nil {
		return nil, err
	}
	byID := map[string]*File{}
	currentIDs := make([]string, 0, len(docs))
	for _, doc := range docs {
		byID[doc.ID] = doc
		currentIDs = append(currentIDs, doc.ID)
	}
	siblingIDs, err := loadSiblingCustomOrder(box.ID, parentDir, existingSorts)
	if err != nil {
		return nil, err
	}
	for _, id := range siblingIDs {
		if byID[id] == nil {
			return nil, fmt.Errorf("document [%s] could not be read", id)
		}
	}
	var fromPaths []string
	for _, id := range sourceIDs {
		source := treenode.GetBlockTree(id)
		if !isSortableDocument(source) || Conf.Box(source.BoxID) == nil {
			return nil, fmt.Errorf("source document [%s] is unavailable", id)
		}
		if source.BoxID == target.BoxID && (target.Path == source.Path ||
			strings.HasPrefix(target.Path, strings.TrimSuffix(source.Path, ".sy")+"/")) {
			return nil, errors.New(Conf.Language(87))
		}
		if byID[id] != nil {
			continue
		}
		sourceParent := path.Dir(source.Path)
		if sourceParent != "/" {
			sourceParent += ".sy"

View on GitHub (pinned to 9f775e8a12)