{"record":{"id":"4e8b00b1be059bfe","repo":"affaan-m/ECC","slug":"memory-frontmatter-field-in-sourcepath-must-use","errorCode":null,"errorMessage":"Memory frontmatter field in ${sourcePath} must use a JSON value.","messagePattern":"Memory frontmatter field in (.+?) must use a JSON value\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/memory-vault-format.js","lineNumber":239,"sourceCode":"\nfunction parseFrontmatterLine(line, sourcePath, seen) {\n  const separator = line.indexOf(':');\n  if (separator <= 0) {\n    throw new Error(`Invalid memory frontmatter line in ${sourcePath}.`);\n  }\n  const serializedKey = line.slice(0, separator).trim();\n  const objectKey = FRONTMATTER_KEYS.get(serializedKey);\n  if (!objectKey) {\n    throw new Error(`Unknown memory frontmatter field in ${sourcePath}.`);\n  }\n  if (seen.has(objectKey)) {\n    throw new Error(`Duplicate memory frontmatter field in ${sourcePath}.`);\n  }\n  const rawValue = line.slice(separator + 1).trim();\n  try {\n    return { objectKey, value: JSON.parse(rawValue) };\n  } catch {\n    throw new Error(`Memory frontmatter field in ${sourcePath} must use a JSON value.`);\n  }\n}\n\nfunction parseMemoryDocument(source, sourcePath = '<memory>') {\n  const openingMarker = typeof source === 'string'\n    ? /^---\\r?\\n/.exec(source)\n    : null;\n  if (!openingMarker) {\n    throw new Error(`Memory document ${sourcePath} must start with --- frontmatter.`);\n  }\n  if (Buffer.byteLength(source, 'utf8') > MAX_DOCUMENT_BYTES) {\n    throw new Error(`Memory document ${sourcePath} is too large.`);\n  }\n\n  const frontmatterStart = openingMarker[0].length;\n  const remainder = source.slice(frontmatterStart);\n  const closingMarker = /\\r?\\n---(?=\\r?\\n|$)/.exec(remainder);\n  if (!closingMarker) {","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/lib/memory-vault-format.js#L221-L257","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n---\ntitle: My Handoff\ntags: [redis, cache]\ncreated_at: 2024-08-12T00:00:00.000Z\n---\n\n// after\n---\ntitle: \"My Handoff\"\ntags: [\"redis\",\"cache\"]\ncreated_at: \"2024-08-12T00:00:00.000Z\"\n---","handlingStrategy":"validation","validationCode":"function isJsonLiteral(valueText) {\n  try { JSON.parse(valueText); return true; } catch { return false; }\n}\nconst valuePart = line.slice(line.indexOf(':') + 1).trim();\nif (!isJsonLiteral(valuePart)) {\n  throw new Error(`frontmatter value is not JSON: ${valueText}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["parsing","frontmatter","json","validation","memory-vault"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}