{"record":{"id":"fe0071ff7464f5f5","repo":"siyuan-note/siyuan","slug":"document-s-could-not-be-read","errorCode":null,"errorMessage":"document [%s] could not be read","messagePattern":"document \\[(.+?)\\] could not be read","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/file_tree_reorder.go","lineNumber":146,"sourceCode":"\t}\n\t// 隐藏文档和超过显示上限的文档也必须参与排序。\n\tdocs, _, err := ListDocTree(box.ID, listPath, mode, false, true, int(^uint(0)>>1))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbyID := map[string]*File{}\n\tcurrentIDs := make([]string, 0, len(docs))\n\tfor _, doc := range docs {\n\t\tbyID[doc.ID] = doc\n\t\tcurrentIDs = append(currentIDs, doc.ID)\n\t}\n\tsiblingIDs, err := loadSiblingCustomOrder(box.ID, parentDir, existingSorts)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfor _, id := range siblingIDs {\n\t\tif byID[id] == nil {\n\t\t\treturn nil, fmt.Errorf(\"document [%s] could not be read\", id)\n\t\t}\n\t}\n\tvar fromPaths []string\n\tfor _, id := range sourceIDs {\n\t\tsource := treenode.GetBlockTree(id)\n\t\tif !isSortableDocument(source) || Conf.Box(source.BoxID) == nil {\n\t\t\treturn nil, fmt.Errorf(\"source document [%s] is unavailable\", id)\n\t\t}\n\t\tif source.BoxID == target.BoxID && (target.Path == source.Path ||\n\t\t\tstrings.HasPrefix(target.Path, strings.TrimSuffix(source.Path, \".sy\")+\"/\")) {\n\t\t\treturn nil, errors.New(Conf.Language(87))\n\t\t}\n\t\tif byID[id] != nil {\n\t\t\tcontinue\n\t\t}\n\t\tsourceParent := path.Dir(source.Path)\n\t\tif sourceParent != \"/\" {\n\t\t\tsourceParent += \".sy\"","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/file_tree_reorder.go#L128-L164","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Remove the stale ID entries from <data>/<boxID>/.siyuan/sort.json and retry","Re-trigger the document reindex (reload notebooks) so disk and sort config agree","Restore the deleted .sy file if the stale entry should still exist","Delete sort.json to fall back to default ordering, then re-apply custom order"],"exampleFix":"// before (retry blindly)\nreorderDocs(sources, target, 'left')\n// after\nconst sorts = JSON.parse(await readSortJson(boxID))\nfor (const id of Object.keys(sorts)) if (!await docExists(id)) delete sorts[id]\nawait writeSortJson(boxID, sorts)\nreorderDocs(sources, target, 'left')","handlingStrategy":"fallback","validationCode":"// prune stale entries from sort.json before reordering\nconst sorts = readSortJson(boxID)\nfor (const id of Object.keys(sorts)) if (!docExistsOnDisk(boxID, id)) delete sorts[id]","typeGuard":null,"tryCatchPattern":"try { await reorderDocs(...) } catch (e) { if (/could not be read/.test(e)) { cleanupSortJson(boxID); await retry() } }","preventionTips":["Do not edit or restore sort.json manually against different data","Let SiYuan handle deletions so the sort config stays in sync","Periodically rebuild notebook indexes after external file changes"],"tags":["sorting","stale-data","document-tree","data-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"}