{"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/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/memory-vault-format.js#L221-L257","documentation":"Frontmatter values must be valid JSON (parseFrontmatterLine runs JSON.parse on the text after the colon). This allows typed values (numbers, arrays for targetHarnesses) but means bare strings must be quoted. Unquoted or malformed values fail JSON.parse and are rejected.","triggerScenarios":"Frontmatter lines like `title: Deploy notes` (unquoted string), `targetHarnesses: [claude]` (unquoted array elements), trailing commas, single quotes, or YAML-style scalars such as `schema: '1'` that are not JSON.","commonSituations":"Users editing the vault markdown expecting YAML semantics (unquoted strings, comment lines with #, single quotes) instead of the actual `key: JSON value` format; templates generated by non-JSON emitters.","solutions":["Quote string values with double quotes: title: \"Deploy notes\".","Ensure arrays are JSON arrays with quoted elements: targetHarnesses: [\"claude\"].","Remove YAML-only syntax (single quotes, unquoted scalars, comments) from frontmatter lines.","Test the value with JSON.parse (e.g. `node -e \"JSON.parse('[1]' )\"`) or re-save via the library to serialize values correctly."],"exampleFix":"// before\n---\ntitle: Deploy notes\ntargetHarnesses: [claude, codex]\n---\n\n// after\n---\ntitle: \"Deploy notes\"\ntargetHarnesses: [\"claude\", \"codex\"]\n---","handlingStrategy":"validation","validationCode":"for (const line of frontmatterLines) {\n  const value = line.slice(line.indexOf(':') + 1).trim();\n  JSON.parse(value); // throws locally if not valid JSON\n}","typeGuard":"const isJsonValue = (s) => { try { JSON.parse(s); return true; } catch { return false; } };","tryCatchPattern":"try {\n  parseMemoryDocument(source, path);\n} catch (err) {\n  if (err.message.includes('must use a JSON value')) {\n    console.error('Frontmatter values in %s must be JSON — quote strings and use JSON arrays.', path);\n  } else throw err;\n}","preventionTips":["Double-quote all string values in frontmatter.","Use JSON array syntax with quoted elements for targetHarnesses.","Avoid YAML-only syntax (single quotes, bare scalars, comments)."],"tags":["json","parsing","frontmatter"],"backgroundTag":"json-parse-error","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}