{"record":{"id":"930ab3eb5da033c5","repo":"earendil-works/pi","slug":"storage-930ab3","errorCode":"storage","errorMessage":"Failed to build SQLite branch cache at entry ${leafId}","messagePattern":"Failed to build SQLite branch cache at entry (.+?)","errorType":"error_code","errorClass":"SessionError","httpStatus":null,"severity":"error","filePath":"packages/session-backends/sqlite-node/src/sqlite/branch-cache.ts","lineNumber":46,"sourceCode":"\tfor (const tip of tips) buildCachedBranch(db, sessionId, tip.id);\n}\n\nexport function buildCachedBranch(db: SqliteDatabase, sessionId: string, leafId: string) {\n\tsql`SAVEPOINT build_branch_cache`.exec(db);\n\ttry {\n\t\tconst branchId = uuidv7();\n\t\tinsertBranchEntriesForPath(db, sessionId, branchId, leafId);\n\t\tinsertBranchTip(db, sessionId, leafId, branchId);\n\t\tsql`RELEASE SAVEPOINT build_branch_cache`.exec(db);\n\t} catch (error) {\n\t\ttry {\n\t\t\tsql`ROLLBACK TO SAVEPOINT build_branch_cache`.exec(db);\n\t\t\tsql`RELEASE SAVEPOINT build_branch_cache`.exec(db);\n\t\t} catch {\n\t\t\t// Preserve the original build failure.\n\t\t}\n\t\tif (error instanceof SessionError) throw error;\n\t\tthrow new SessionError(\n\t\t\t\"storage\",\n\t\t\t`Failed to build SQLite branch cache at entry ${leafId}`,\n\t\t\terror instanceof Error ? error : undefined,\n\t\t);\n\t}\n}\n\nfunction extendBranch(\n\tdb: SqliteDatabase,\n\tsessionId: string,\n\tbranchId: string,\n\tparentId: string,\n\tentryId: string,\n\tentrySeq: number,\n\tentryType: string,\n\tcustomType: string | null,\n) {\n\tinsertBranchEntry(db, sessionId, branchId, entryId, entrySeq, entryType, customType);","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/session-backends/sqlite-node/src/sqlite/branch-cache.ts#L28-L64","documentation":"Error \"Failed to build SQLite branch cache at entry ${leafId}\" thrown in earendil-works/pi.","triggerScenarios":"Thrown at packages/session-backends/sqlite-node/src/sqlite/branch-cache.ts:46 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The branch cache rebuild failed at the reported entry; check database integrity around that leaf."],"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"}