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

  1. Write the value as a JSON array string: CLAUDE_MEM_FOLDER_MD_EXCLUDE=["node_modules","dist","build"]
  2. Validate before running: `node -e 'JSON.parse(process.argv[1])' 'your-value'` must exit cleanly.
  3. Leave the setting unset to use the empty default rather than writing malformed values.
  4. 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

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

Related errors


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)