affaan-m/ECC · error · Error
Memory frontmatter field in ${sourcePath} must use a JSON va
Error message
Memory frontmatter field in ${sourcePath} must use a JSON value. What it means
Thrown by parseFrontmatterLine() when JSON.parse() fails on the value portion of a frontmatter line. The parser requires every value to be a JSON literal — strings must be double-quoted, arrays use JSON syntax, numbers/booleans/null are bare. Unquoted strings, single-quoted strings, YAML-style lists, and trailing commas all fail.
Source
Thrown at scripts/lib/memory-vault-format.js:239
function parseFrontmatterLine(line, sourcePath, seen) {
const separator = line.indexOf(':');
if (separator <= 0) {
throw new Error(`Invalid memory frontmatter line in ${sourcePath}.`);
}
const serializedKey = line.slice(0, separator).trim();
const objectKey = FRONTMATTER_KEYS.get(serializedKey);
if (!objectKey) {
throw new Error(`Unknown memory frontmatter field in ${sourcePath}.`);
}
if (seen.has(objectKey)) {
throw new Error(`Duplicate memory frontmatter field in ${sourcePath}.`);
}
const rawValue = line.slice(separator + 1).trim();
try {
return { objectKey, value: JSON.parse(rawValue) };
} catch {
throw new Error(`Memory frontmatter field in ${sourcePath} must use a JSON value.`);
}
}
function parseMemoryDocument(source, sourcePath = '<memory>') {
const openingMarker = typeof source === 'string'
? /^---\r?\n/.exec(source)
: null;
if (!openingMarker) {
throw new Error(`Memory document ${sourcePath} must start with --- frontmatter.`);
}
if (Buffer.byteLength(source, 'utf8') > MAX_DOCUMENT_BYTES) {
throw new Error(`Memory document ${sourcePath} is too large.`);
}
const frontmatterStart = openingMarker[0].length;
const remainder = source.slice(frontmatterStart);
const closingMarker = /\r?\n---(?=\r?\n|$)/.exec(remainder);
if (!closingMarker) {View on GitHub (pinned to 01e15490f0)
Solutions
- Wrap every string value in double quotes: title: "My Note".
- Use JSON arrays: tags: ["a","b","c"].
- Quote timestamps so the colon inside does not confuse splitting: created_at: "2024-08-12T00:00:00.000Z".
- Regenerate the file via serializeMemoryDocument(); it always emits valid JSON values.
Example fix
// before --- title: My Handoff tags: [redis, cache] created_at: 2024-08-12T00:00:00.000Z --- // after --- title: "My Handoff" tags: ["redis","cache"] created_at: "2024-08-12T00:00:00.000Z" ---
Defensive patterns
Strategy: validation
Validate before calling
function isJsonLiteral(valueText) {
try { JSON.parse(valueText); return true; } catch { return false; }
}
const valuePart = line.slice(line.indexOf(':') + 1).trim();
if (!isJsonLiteral(valuePart)) {
throw new Error(`frontmatter value is not JSON: ${valueText}`);
} Prevention
- Double-quote every string value, including timestamps (they contain colons).
- Use JSON array syntax for tags/links/target_harnesses: ["a","b"].
- Do not use YAML block lists or single-quoted strings — only JSON.
When it happens
Trigger: A line 'title: My Note' (unquoted string), 'title: \'My Note\'' (single quotes), 'tags: [a, b, c]' (unquoted array elements), 'tags:\n - a' (YAML block style), or 'created_at: 2024-08-12T...' (unquoted timestamp). All of these are valid YAML but invalid JSON.
Common situations: User familiar with YAML wrote frontmatter by hand. AI agent copied from a YAML-frontmatter doc (jekyll/hugo style). Editor auto-formatted to YAML conventions. Field value contains a colon, breaking naive colon-splitting unless quoted.
Related errors
- Invalid memory frontmatter line in ${sourcePath}.
- Unknown memory frontmatter field in ${sourcePath}.
- Duplicate memory frontmatter field in ${sourcePath}.
- Memory document ${sourcePath} must start with --- frontmatte
- Memory document ${sourcePath} has no closing frontmatter mar
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/4e8b00b1be059bfe.
Report an issue: GitHub.