{"record":{"id":"6eff596db43b7af2","repo":"affaan-m/ECC","slug":"invalid-memory-frontmatter-line-in-sourcepath","errorCode":null,"errorMessage":"Invalid memory frontmatter line in ${sourcePath}.","messagePattern":"Invalid memory frontmatter line in (.+?)\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/memory-vault-format.js","lineNumber":225,"sourceCode":"  const metadata = FRONTMATTER_FIELDS.map(([serializedKey, objectKey]) => (\n    `${serializedKey}: ${JSON.stringify(normalized[objectKey])}`\n  )).join('\\n');\n  const body = normalized.body.length > 0 ? `\\n\\n${normalized.body}` : '';\n  return `---\\n${metadata}\\n---${body}\\n`;\n}\n\nfunction decodeUtf8(buffer, label = 'text') {\n  try {\n    return FATAL_UTF8_DECODER.decode(buffer);\n  } catch {\n    throw new Error(`${label} must contain valid UTF-8 text.`);\n  }\n}\n\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>') {","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/lib/memory-vault-format.js#L207-L243","documentation":"Thrown by parseFrontmatterLine() when a line in the frontmatter block has no ':' separator, or the ':' is at index 0 (empty key). Every frontmatter line must be of the form 'serialized_key: JSON-value'. Lines that are blank, comments, plain prose, or use '=' instead of ':' are rejected — the parser is intentionally YAML-subset-strict to avoid ambiguous parsing.","triggerScenarios":"A memory file containing a blank line inside the frontmatter block, a comment like '# this is the title', a line 'title = My Note' using TOML/INI syntax, or a line that is just 'title' with the value on the next line.","commonSituations":"User hand-edited the .md file and added a comment. Editor auto-inserted a blank line on save. Copy-paste from a YAML file that uses 'key: value' but with leading whitespace that confused the parser. AI agent wrote frontmatter without the colon when the value was empty.","solutions":["Open the file at the path reported in sourcePath and inspect each frontmatter line for a missing colon.","Remove blank lines and comments from between the --- markers; comments belong in the body.","Always use the form 'key: <JSON-value>' — for strings that means 'key: \"value\"'.","Regenerate the file via serializeMemoryDocument(memory) rather than hand-editing."],"exampleFix":"// before — file contents\n---\ntitle \"handoff\"          # missing colon\n# author: bob            # comment line inside frontmatter\nkind: note\n---\n\n// after\n---\ntitle: \"handoff\"\nkind: \"note\"\n---","handlingStrategy":"validation","validationCode":"function isValidFrontmatterLine(line) {\n  const sep = line.indexOf(':');\n  return sep > 0;\n}\nlines.forEach(line => {\n  if (line.length > 0 && !isValidFrontmatterLine(line)) {\n    throw new Error(`frontmatter line is malformed: ${JSON.stringify(line)}`);\n  }\n});","typeGuard":null,"tryCatchPattern":"try {\n  parseMemoryDocument(source, path);\n} catch (err) {\n  if (/Invalid memory frontmatter line/.test(err.message)) {\n    reportToUser(path, 'each frontmatter line must be \"key: <JSON-value>\"');\n  }\n  throw err;\n}","preventionTips":["Do not put comments or blank lines inside the frontmatter block.","Author files via serializeMemoryDocument() rather than by hand.","After hand-editing, run doctorMemoryVault() to catch malformed lines."],"tags":["parsing","frontmatter","validation","memory-vault"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}