siyuan-note/siyuan · error
target ID [ ] must not be included in source IDs
Error message
target ID [%s] must not be included in source IDs
What it means
A reorder's target document is the reference point, so it cannot itself be one of the moved sources. validateReorderArgs scans sourceIDs and rejects the request if any ID equals targetID. This prevents self-referential ordering that has no defined result.
Solutions
- Exclude targetID from sourceIDs before calling the reorder API
- Fix the drag-and-drop selection logic so the drop anchor is removed from the moved set
- Deduplicate against the target when assembling the request programmatically
Example fix
// before reorderDocs(selectedIDs, targetID, "after") // after const sources = selectedIDs.filter(id => id !== targetID) reorderDocs(sources, targetID, "after")
Defensive patterns
Strategy: validation
Validate before calling
const sources = [...new Set(sourceIDs.filter(id => id !== targetID))]
if (sources.length !== sourceIDs.length) { /* anchor was in the moved set; use filtered list */ } Try / catch
try { await api.reorderDocs(src, targetID, pos) } catch (e) { if (String(e).includes("must not be included in source IDs")) { src = src.filter(id => id !== targetID); return retryOnce() } throw e } Prevention
- Always remove the drop anchor from the selection before building the request
- In multi-select drag, detect if the drag origin is the drop target and treat it as a no-op
- Filter against targetID as the last step before sending
When it happens
Trigger: Including the drop-target document in the dragged selection; batch scripts appending the anchor ID to the source list; UI code where the drop indicator landed on a selected document.
Common situations: Multi-select drag where the user starts the drag on an already-selected item that is also the drop target; automation building source lists from a range that includes the anchor.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- invalid reorder position
- block [ ] is not a document that can declare a child…
- Conf.Language(112)
- document IDs are required
- duplicate source ID [ ]
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/58731dbd75a0c0b0.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/file.go:2751
ret.Changed = true
ret.Notebook = box.ID
ret.ParentPath = parentPath
IncSync()
pushFiletreeSortChanged(sortIDs)
return
}
func validateReorderArgs(sourceIDs []string, targetID, position string) error {
if 1 > len(sourceIDs) {
return errors.New("source IDs must not be empty")
}
if "before" != position && "after" != position {
return fmt.Errorf("invalid reorder position [%s]", position)
}
seen := map[string]struct{}{}
for _, sourceID := range sourceIDs {
if sourceID == targetID {
return fmt.Errorf("target ID [%s] must not be included in source IDs", targetID)
}
if _, ok := seen[sourceID]; ok {
return fmt.Errorf("duplicate source ID [%s]", sourceID)
}
seen[sourceID] = struct{}{}
}
return nil
}
func isSortableDocument(tree *treenode.BlockTree) bool {
return nil != tree && tree.ID == tree.RootID && "d" == tree.Type && !IsBoxDoc(tree.BoxID, tree.RootID)
}
func loadSiblingCustomOrder(boxID, parentPath string, fullSortIDs map[string]int) (ret []string, err error) {
absParentPath := filepath.Join(util.DataDir, boxID, parentPath)
files, err := os.ReadDir(absParentPath)
if nil != err {
return nil, fmt.Errorf("read dir [%s] failed: %w", absParentPath, err)View on GitHub (pinned to 9f775e8a12)