toeverything/AFFiNE · error · Error
Target node not found
Error message
Target node not found
What it means
indexAt throws when an explicit targetId is given but it is not present among the currently sorted pinned collections, so a fractional index relative to the target cannot be computed — the target was unpinned or the id is invalid.
Source
Thrown at packages/frontend/core/src/modules/collection/services/pinned-collection.ts:56
this.pinnedCollectionStore.removePinnedCollection(collectionId);
}
indexAt(at: 'before' | 'after', targetId?: string) {
if (!targetId) {
if (at === 'before') {
const first = this.sortedPinnedCollections$.value.at(0);
return generateFractionalIndexingKeyBetween(null, first?.index || null);
} else {
const last = this.sortedPinnedCollections$.value.at(-1);
return generateFractionalIndexingKeyBetween(last?.index || null, null);
}
} else {
const sortedChildren = this.sortedPinnedCollections$.value;
const targetIndex = sortedChildren.findIndex(
node => node.collectionId === targetId
);
if (targetIndex === -1) {
throw new Error('Target node not found');
}
const target = sortedChildren[targetIndex];
const before: PinnedCollectionRecord | null =
sortedChildren[targetIndex - 1] || null;
const after: PinnedCollectionRecord | null =
sortedChildren[targetIndex + 1] || null;
if (at === 'before') {
return generateFractionalIndexingKeyBetween(
before?.index || null,
target.index
);
} else {
return generateFractionalIndexingKeyBetween(
target.index,
after?.index || null
);
}
}View on GitHub (pinned to b4c8548c09)
Solutions
- Ensure the target node exists before pinning; refresh the collection tree.
- Remove stale pinned entries referencing deleted nodes.
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown in pinned-collection indexAt when the target collection id is not found among the sorted pinned collections.
Common situations: Occurs when reordering a pinned collection that is no longer pinned or whose list has changed; refresh the pinned list before moving items.
AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18).
Data as JSON: /api/errors/9ce25e82b4215a17.
Report an issue: GitHub.