{"record":{"id":"9ce25e82b4215a17","repo":"toeverything/AFFiNE","slug":"target-node-not-found","errorCode":null,"errorMessage":"Target node not found","messagePattern":"Target node not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/frontend/core/src/modules/collection/services/pinned-collection.ts","lineNumber":56,"sourceCode":"    this.pinnedCollectionStore.removePinnedCollection(collectionId);\n  }\n\n  indexAt(at: 'before' | 'after', targetId?: string) {\n    if (!targetId) {\n      if (at === 'before') {\n        const first = this.sortedPinnedCollections$.value.at(0);\n        return generateFractionalIndexingKeyBetween(null, first?.index || null);\n      } else {\n        const last = this.sortedPinnedCollections$.value.at(-1);\n        return generateFractionalIndexingKeyBetween(last?.index || null, null);\n      }\n    } else {\n      const sortedChildren = this.sortedPinnedCollections$.value;\n      const targetIndex = sortedChildren.findIndex(\n        node => node.collectionId === targetId\n      );\n      if (targetIndex === -1) {\n        throw new Error('Target node not found');\n      }\n      const target = sortedChildren[targetIndex];\n      const before: PinnedCollectionRecord | null =\n        sortedChildren[targetIndex - 1] || null;\n      const after: PinnedCollectionRecord | null =\n        sortedChildren[targetIndex + 1] || null;\n      if (at === 'before') {\n        return generateFractionalIndexingKeyBetween(\n          before?.index || null,\n          target.index\n        );\n      } else {\n        return generateFractionalIndexingKeyBetween(\n          target.index,\n          after?.index || null\n        );\n      }\n    }","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/frontend/core/src/modules/collection/services/pinned-collection.ts#L38-L74","documentation":"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.","triggerScenarios":"Thrown in pinned-collection indexAt when the target collection id is not found among the sorted pinned collections.","commonSituations":"Occurs when reordering a pinned collection that is no longer pinned or whose list has changed; refresh the pinned list before moving items.","solutions":["Ensure the target node exists before pinning; refresh the collection tree.","Remove stale pinned entries referencing deleted nodes."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}