{"record":{"id":"c3d5cd5ed408c78a","repo":"siyuan-note/siyuan","slug":"source-document-s-not-found","errorCode":null,"errorMessage":"source document [%s] not found","messagePattern":"source document \\[(.+?)\\] not found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/file.go","lineNumber":2698,"sourceCode":"\tret = &ReorderResult{}\n\tif err = validateReorderArgs(sourceIDs, targetID, position); nil != err {\n\t\treturn\n\t}\n\n\tFlushTxQueue()\n\ttarget := treenode.GetBlockTree(targetID)\n\tif !isSortableDocument(target) {\n\t\treturn ret, fmt.Errorf(\"target document [%s] not found\", targetID)\n\t}\n\tbox := Conf.Box(target.BoxID)\n\tif nil == box {\n\t\treturn ret, fmt.Errorf(\"target document [%s] is not in an opened and unlocked notebook\", targetID)\n\t}\n\tparentPath := path.Dir(target.Path)\n\tfor _, sourceID := range sourceIDs {\n\t\tsource := treenode.GetBlockTree(sourceID)\n\t\tif !isSortableDocument(source) {\n\t\t\treturn ret, fmt.Errorf(\"source document [%s] not found\", sourceID)\n\t\t}\n\t\tif source.BoxID != target.BoxID || path.Dir(source.Path) != parentPath {\n\t\t\treturn ret, fmt.Errorf(\"source document [%s] is not a sibling of target document [%s]\", sourceID, targetID)\n\t\t}\n\t}\n\n\tfileTreeSortLock.Lock()\n\tconfPath := filepath.Join(util.DataDir, box.ID, \".siyuan\", \"sort.json\")\n\tfullSortIDs, readErr := readSortConfMap(confPath)\n\tif nil != readErr {\n\t\tfileTreeSortLock.Unlock()\n\t\treturn ret, readErr\n\t}\n\tcurrentIDs, loadErr := loadSiblingCustomOrder(box.ID, parentPath, fullSortIDs)\n\tif nil != loadErr {\n\t\tfileTreeSortLock.Unlock()\n\t\treturn ret, loadErr\n\t}","sourceCodeStart":2680,"sourceCodeEnd":2716,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/file.go#L2680-L2716","documentation":"Each source document is resolved with treenode.GetBlockTree and must be a sortable document, same as the target. If a source ID does not resolve to an existing document block, the whole reorder fails with this error before any change is applied. The check is all-or-nothing so a single bad ID aborts the batch.","triggerScenarios":"Batch reorder call where one element of sourceIDs references a deleted/nonexistent document or a non-document block; stale IDs captured before a sync removed the documents.","commonSituations":"Plugins assembling source lists from stale UI selections; user deleting a document in another device/session then the local client attempting the queued reorder; concatenated IDs from different notebooks.","solutions":["Filter sourceIDs through an existence check (GetBlockTree equivalent / document listing) before calling the reorder API","Refresh the UI tree and reselect the documents, then retry the reorder","Identify the offending ID from the error message and remove it from the batch","If IDs came from sync/queue state, wait for indexing to settle and rebuild the list"],"exampleFix":"// before\nreorderDocs(allIDs, targetID, \"after\")\n// after\nconst valid = allIDs.filter(id => docExists(id))\nreorderDocs(valid, targetID, \"after\")","handlingStrategy":"validation","validationCode":"const existing = new Set((await listDocIDs(notebookId)))\nconst missing = sourceIDs.filter(id => !existing.has(id))\nif (missing.length) throw new Error(`missing sources: ${missing.join(\",\")}`)","typeGuard":null,"tryCatchPattern":"try { await api.reorderDocs(src, targetID, pos) } catch (e) { if (String(e).includes(\"source document\") && String(e).includes(\"not found\")) { src = src.filter(docExists); return retryOnce() } throw e }","preventionTips":["Validate every source ID against a fresh document listing before batching","Purge stale IDs from queues after sync deletions","Fail fast per batch and report the exact offending ID to the user"],"tags":["go","kernel","document","not-found"],"backgroundTag":"entity-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"}