siyuan-note/siyuan · error
source ID [ ] is not in the current order
Error message
source ID [%s] is not in the current order
What it means
During custom-sort application, every sourceID being moved is checked against the current sibling order (currentSet). Any sourceID not present in currentIDs aborts the whole operation with "source ID [%s] is not in the current order". This is the symmetric check to error 1391 and protects order integrity when the source document has vanished or changed parents.
Solutions
- Re-fetch the current sibling list and rebuild sourceIDs from documents that still exist under the parent
- Filter out stale sourceIDs client-side before sending the sort request
- Check that all sourceIDs are root document IDs of the same parent as targetID
Example fix
// before
MoveDocsSort(sourceIDs, targetID, pos)
// after: prune sources that no longer exist in the order
currentIDs, _ := loadSiblingCustomOrder(boxID, parentPath, nil)
valid := make([]string, 0, len(sourceIDs))
for _, id := range sourceIDs {
if slices.Contains(currentIDs, id) {
valid = append(valid, id)
}
}
MoveDocsSort(valid, targetID, pos) Defensive patterns
Strategy: validation
Validate before calling
const currentIDs = await api.getChildDocs(parentID); const bad = sourceIDs.filter(id => !currentIDs.includes(id)); if (bad.length) sourceIDs = sourceIDs.filter(id => currentIDs.includes(id));
Type guard
const allValidSources = (ids, currentIDs) => Array.isArray(ids) && ids.every(id => currentIDs.includes(id));
Try / catch
try { await api.sortDocs(sourceIDs, targetID, pos); } catch (e) { if (String(e).match(/source ID .* not in the current order/)) { sourceIDs = await revalidateSources(); retry(); } else { throw e; } } Prevention
- Re-fetch siblings after any concurrent edit before multi-select sorts
- Compact selection arrays so they contain only existing documents
- Avoid batching sort operations across windows without reconciliation
When it happens
Trigger: Calling the sort-application API where sourceIDs contains an ID absent from currentIDs — deleted source document, source moved to another parent, duplicate/malformed client request listing a non-sibling ID.
Common situations: Multi-select drag where one of the selected docs was deleted by another window; batch operations built before a sync reconciled documents; client bug sending child-block IDs instead of document root IDs.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- target ID [ ] is not in the current order
- duplicate notebook ID
- all asset mappings failed
- assetPath is not an image referenced by the document
- assetPath is required for analyze
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/8486b50ca0eb781c.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/model/file.go:2817
}
return mergeRequestedIDOrder(currentIDs, requestedIDs)
}
func reorderIDSequence(currentIDs, sourceIDs []string, targetID, position string) (ret []string, changed bool, err error) {
if err = validateReorderArgs(sourceIDs, targetID, position); nil != err {
return
}
currentSet := make(map[string]struct{}, len(currentIDs))
for _, id := range currentIDs {
currentSet[id] = struct{}{}
}
if _, exists := currentSet[targetID]; !exists {
return nil, false, fmt.Errorf("target ID [%s] is not in the current order", targetID)
}
sourceSet := make(map[string]struct{}, len(sourceIDs))
for _, sourceID := range sourceIDs {
if _, exists := currentSet[sourceID]; !exists {
return nil, false, fmt.Errorf("source ID [%s] is not in the current order", sourceID)
}
sourceSet[sourceID] = struct{}{}
}
remaining := make([]string, 0, len(currentIDs)-len(sourceIDs))
for _, id := range currentIDs {
if _, source := sourceSet[id]; !source {
remaining = append(remaining, id)
}
}
targetIndex := -1
for i, id := range remaining {
if id == targetID {
targetIndex = i
break
}
}
if "after" == position {
targetIndex++View on GitHub (pinned to 9f775e8a12)