{"record":{"id":"3368625ea1b0028c","repo":"earendil-works/pi","slug":"already-exists-336862","errorCode":"already_exists","errorMessage":"ID already exists: ${id}","messagePattern":"ID already exists: (.+?)","errorType":"error_code","errorClass":"SessionError","httpStatus":null,"severity":"error","filePath":"packages/session-backends/sqlite-node/src/sqlite/repo.ts","lineNumber":323,"sourceCode":"\t\tconst current = path[index]!;\n\t\tif (current.parent_id !== previous.id) {\n\t\t\tthrow new SessionError(\"invalid_entry\", `Entry ${current.parent_id} not found`);\n\t\t}\n\t}\n}\n\nfunction matchesEntryQuery(entry: Entry, query: EntryQuery): boolean {\n\treturn (\n\t\t(query.type === undefined || entry.type === query.type) &&\n\t\t(query.customType === undefined || (entry.type === \"custom\" && entry.customType === query.customType)) &&\n\t\t(query.cursor === undefined ||\n\t\t\t(query.order === \"oldestFirst\" ? entry.seq > query.cursor.afterSeq : entry.seq < query.cursor.afterSeq))\n\t);\n}\n\nfunction assertUnusedId(db: SqliteDatabase, sessionId: string, id: string): void {\n\tif (idExistsInEntries(db, sessionId, id) || idExistsInRecords(db, sessionId, id)) {\n\t\tthrow new SessionError(\"already_exists\", `ID already exists: ${id}`);\n\t}\n}\n\nfunction requireSessionRow(db: SqliteDatabase, sessionId: string): SessionRow {\n\tconst row = readSessionRow(db, sessionId);\n\tif (!row) throw new SessionError(\"not_found\", `Session not found: ${sessionId}`);\n\treturn row;\n}\n\nclass SqliteSessionStorage implements SessionStorage<SqliteSessionMetadata> {\n\tprivate readonly db: SqliteDatabase;\n\tprivate readonly metadata: SqliteSessionMetadata;\n\tprivate readonly lease: WriterLease;\n\tprivate readonly leaseOptions: ResolvedWriterLeaseOptions;\n\tprivate readonly onRelease: () => void;\n\tprivate readonly operations = new SerialOperationQueue();\n\tprivate heartbeatTimer: ReturnType<typeof setTimeout> | undefined;\n\tprivate leaseError: SessionError | undefined;","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/session-backends/sqlite-node/src/sqlite/repo.ts#L305-L341","documentation":"Error \"ID already exists: ${id}\" thrown in earendil-works/pi.","triggerScenarios":"Thrown at packages/session-backends/sqlite-node/src/sqlite/repo.ts:323 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a unique id; an entry with this id already exists."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4af9d21d3b4d664e4a29fcabfec85171077248e3","analyzedAt":"2026-08-24T13:07:14.692Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}