thedotmack/claude-mem · warning
generation parse error
Error message
generation parse error: ${outcome.reason} What it means
When generating folder-level CLAUDE.md files, the code JSON.parses the CLAUDE_MEM_FOLDER_MD_EXCLUDE settings string, expecting a JSON array of glob strings (default '[]'). The parse threw — the setting is present but not valid JSON (e.g. a bare comma-separated list). The handler warns under FOLDER_INDEX and continues with an empty exclude list, so every folder gets folder-md treatment.
Solutions
- Write the value as a JSON array string: CLAUDE_MEM_FOLDER_MD_EXCLUDE=["node_modules","dist","build"]
- Validate before running: `node -e 'JSON.parse(process.argv[1])' 'your-value'` must exit cleanly.
- Leave the setting unset to use the empty default rather than writing malformed values.
- Apply the same fix to CLAUDE_MEM_FOLDER_MD_SKELETON_DENYLIST, which fails identically one block later.
Example fix
# before CLAUDE_MEM_FOLDER_MD_EXCLUDE=dist,build # after CLAUDE_MEM_FOLDER_MD_EXCLUDE=["dist","build"]
Defensive patterns
Strategy: validation
Validate before calling
// Validate list-shaped settings BEFORE the pipeline that consumes them
function parseJsonStringArray(raw: string | undefined, name: string): string[] {
if (!raw) return [];
try {
const parsed: unknown = JSON.parse(raw);
if (Array.isArray(parsed) && parsed.every(p => typeof p === 'string')) return parsed;
} catch { /* fall through */ }
throw new Error(`${name} must be a JSON array of strings, got: ${raw}`);
}
const folderMdExcludePaths = parseJsonStringArray(settings.CLAUDE_MEM_FOLDER_MD_EXCLUDE, 'CLAUDE_MEM_FOLDER_MD_EXCLUDE'); Type guard
function isStringArray(value: unknown): value is string[] {
return Array.isArray(value) && value.every(v => typeof v === 'string');
} Prevention
- Always write these settings as JSON array literals: ["a","b"], never comma-separated lists.
- Add a settings lint step (`node -e 'JSON.parse(v)'`) to startup or CI for every *_EXCLUDE-style variable.
- Quote env values in shells so inner double quotes survive: export X='["dist","build"]'.
When it happens
Trigger: Setting CLAUDE_MEM_FOLDER_MD_EXCLUDE=dist,build instead of ["dist","build"]; unbalanced quotes or trailing commas; shell quoting mangling the value when exporting in a dotfile or CI.
Common situations: Hand-editing .claude-mem settings; copying an example with smart quotes from docs/chat; CI environment variables losing inner quotes.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- generation job not found in scope
- [SETTINGS] Failed to load settings, using defaults:
- Anthropic API rejected request with HTTP 400: this model…
- auth_invalid
- auth_invalid
AI-assisted analysis of thedotmack/claude-mem@e2d1df569a (2026-08-20).
Data as JSON: /api/errors/aa13888af9876f9c.
Report an issue: GitHub.
Appendix: source
Thrown at src/server/generation/ProviderObservationGenerator.ts:262
apiKeyId: payload.api_key_id,
actorId: payload.actor_id,
sourceAdapter: payload.source_adapter,
...(this.options.workerId !== undefined ? { workerId: this.options.workerId } : {}),
};
const outcome: ProcessGeneratedResponseOutcome = fresh.sourceType === 'session_summary'
? await processSessionSummaryResponse(persistInput)
: await processGeneratedResponse(persistInput);
if (outcome.kind === 'parse_error') {
await markGenerationFailed({
pool: this.options.pool,
job: fresh,
reason: outcome.reason,
classification: 'parse_error',
retryable: false,
...(this.options.workerId !== undefined ? { workerId: this.options.workerId } : {}),
});
throw new Error(`generation parse error: ${outcome.reason}`);
}
logger.info('SYSTEM', 'generation completed', {
correlationId,
jobId: outcome.jobId,
bullmqJobId: job.id ?? null,
requestId: payloadRequestId,
observationCount: outcome.observations.length,
privateContentDetected: outcome.privateContentDetected,
});
return {
jobId: outcome.jobId,
status: 'completed',
observationCount: outcome.observations.length,
};
}
View on GitHub (pinned to e2d1df569a)