{"record":{"id":"8deb5fb6163a6882","repo":"siyuan-note/siyuan","slug":"source-document-s-is-not-a-sibling-of-target-do","errorCode":null,"errorMessage":"source document [%s] is not a sibling of target document [%s]","messagePattern":"source document \\[(.+?)\\] is not a sibling of target document \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/file.go","lineNumber":2701,"sourceCode":"\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}\n\torderedIDs, changed, reorderErr := reorderIDSequence(currentIDs, sourceIDs, targetID, position)\n\tif nil != reorderErr || !changed {\n\t\tfileTreeSortLock.Unlock()","sourceCodeStart":2683,"sourceCodeEnd":2719,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/file.go#L2683-L2719","documentation":"Documents can only be reordered among their siblings: every source must be in the same notebook (source.BoxID == target.BoxID) and in the same parent directory (path.Dir(source.Path) == parentPath). If any source violates this, the reorder is rejected. This keeps the operation a pure reordering within one parent rather than a move between parents.","triggerScenarios":"Passing source documents from a different notebook than the target; passing sources whose parent is a different document/folder than the target's parent (e.g. dragging across levels in the file tree).","commonSituations":"UI or plugin drag-and-drop implementations allowing cross-level drops; mixing IDs from search results spanning multiple parents; assuming reorder can substitute for a move operation.","solutions":["Group source documents by their parent document and issue one reorder call per sibling group","Use the document move API instead when the intent is to relocate documents across parents/notebooks","Verify each source's notebook and parent path match the target's before calling","Fix the drag-and-drop logic so cross-parent drops trigger move, not reorder"],"exampleFix":"// before\nreorderDocs(mixedIDs, targetID, \"after\") // sources span parents\n// after\nconst siblings = mixedIDs.filter(id => parentOf(id) === parentOf(targetID))\nreorderDocs(siblings, targetID, \"after\")","handlingStrategy":"validation","validationCode":"const targetParent = parentPathOf(targetID)\nconst siblings = sourceIDs.filter(id => notebookOf(id) === target.notebookId && parentPathOf(id) === targetParent)\nif (siblings.length !== sourceIDs.length) { /* route non-siblings to the move API instead */ }","typeGuard":null,"tryCatchPattern":"try { await api.reorderDocs(src, targetID, pos) } catch (e) { if (String(e).includes(\"is not a sibling\")) { await api.moveDocs(src, targetParentDocID); return retryOnce() } throw e }","preventionTips":["Group reorder requests strictly by parent document","Use the move API for anything crossing notebooks or parents","Enforce same-parent drops in drag-and-drop handlers (disable cross-level drop indicators)"],"tags":["go","kernel","document","hierarchy"],"backgroundTag":"invalid-argument-value","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"}