fix: add null guards for getChromaSync() when Chroma is disabled (#1336)

When CLAUDE_MEM_CHROMA_ENABLED=false, getChromaSync() returns null.
Two call sites were missing null guards, causing "null is not an object"
errors on every UserPromptSubmit / session init.

Fixes #1294

Vibe-coded by Ousama Ben Younes

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Ben Younes
2026-03-13 03:58:03 +01:00
committed by GitHub
parent 4616f7ab1c
commit 503bda4868
2 changed files with 4 additions and 1 deletions
+3
View File
@@ -61,6 +61,9 @@ export class SearchManager {
limit: number,
whereFilter?: Record<string, any>
): Promise<{ ids: number[]; distances: number[]; metadatas: any[] }> {
if (!this.chromaSync) {
return { ids: [], distances: [], metadatas: [] };
}
return await this.chromaSync.queryChroma(query, limit, whereFilter);
}
@@ -356,7 +356,7 @@ export class SessionRoutes extends BaseRouteHandler {
// Sync user prompt to Chroma
const chromaStart = Date.now();
const promptText = latestPrompt.prompt_text;
this.dbManager.getChromaSync().syncUserPrompt(
this.dbManager.getChromaSync()?.syncUserPrompt(
latestPrompt.id,
latestPrompt.memory_session_id,
latestPrompt.project,