{"record":{"id":"bfadc00b26e2f33e","repo":"thedotmack/claude-mem","slug":"prompt-watermark-bump-skipped-write-failed-row-marked","errorCode":null,"errorMessage":"Prompt watermark bump skipped — write failed, row marked pending","messagePattern":"Prompt watermark bump skipped — write failed, row marked pending","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/services/sync/ChromaSync.ts","lineNumber":626,"sourceCode":"      project: project,\n      platform_source: normalizePlatformSource(platformSource)\n    };\n\n    const document = this.formatUserPromptDoc(stored);\n\n    logger.info('CHROMA_SYNC', 'Syncing user prompt', {\n      promptId,\n      project\n    });\n\n    // Only bump on a confirmed full write — see syncObservation() for rationale.\n    const written = await this.addDocuments([document]);\n    if (written === 1) {\n      ChromaSyncState.clearPending(project, 'prompts', [promptId]);\n      ChromaSyncState.bump(project, 'prompts', promptId);\n    } else {\n      ChromaSyncState.markPending(project, 'prompts', [promptId]);\n      logger.warn('CHROMA_SYNC', 'Prompt watermark bump skipped — write failed, row marked pending', {\n        promptId,\n        project,\n        written\n      });\n    }\n  }\n\n  private mergeRowsById<T extends { id: number }>(rows: T[], pendingRows: T[]): T[] {\n    const merged = new Map<number, T>();\n    for (const row of rows) {\n      merged.set(row.id, row);\n    }\n    for (const row of pendingRows) {\n      merged.set(row.id, row);\n    }\n    return [...merged.values()].sort((a, b) => a.id - b.id);\n  }\n","sourceCodeStart":608,"sourceCodeEnd":644,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/services/sync/ChromaSync.ts#L608-L644","documentation":"syncUserPrompt writes a single prompt document; if addDocuments does not report exactly 1 written document, the prompts watermark is not advanced, the prompt id is marked pending, and this warning is logged so backfill retries it.","triggerScenarios":"addDocuments([document]) returns written !== 1, i.e. 0 — the Chroma upsert failed entirely (connection error, invalid document, collection unavailable).","commonSituations":"Chroma down or restarting, oversized prompt content rejected, embedding failure for the prompt text.","solutions":["Check the Chroma client error behind written=0 in logs.","Rely on the pending mark so the next backfill re-syncs the prompt.","Verify Chroma connectivity and collection existence.","If prompts are oversized, truncate or chunk prompt content before sync."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"const written = await this.addDocuments([document]);\nif (written !== 1) console.warn(`prompt write failed, written=${written}; pending retry expected`);","typeGuard":null,"tryCatchPattern":"try { await syncUserPrompt(...); }\ncatch (e) { /* row marked pending; backfill retries */ }","preventionTips":["Check Chroma availability before sync sessions","Truncate oversized prompt content","Treat written!==1 as retryable, not fatal"],"tags":["sync","watermark","write-failed","chroma"],"backgroundTag":"database-write-failed","analyzedSha":"d8bc9755e74915e5c3b999181e10a67c889bce2a","analyzedAt":"2026-09-17T16:40:26.182Z","contentChangedAt":"2026-09-17T16:40:26.182Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}