{"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/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/memory-vault-format.js#L207-L243","documentation":"parseFrontmatterLine() parses one `key: value` line of a memory document's frontmatter. It requires a colon at position > 0 (i.e. a non-empty key followed by a colon). A line without any colon, or starting with a colon, is structurally invalid frontmatter and is rejected with the source path in the message.","triggerScenarios":"A frontmatter line like `title Deploy notes` (missing colon), `: value` (empty key), stray text lines inside the --- block, or a key containing only whitespace before the colon; also triggered by a colon-only line or tab-formatted continuation lines.","commonSituations":"Hand-editing the markdown vault and deleting a colon; a YAML-style block (nested keys, lists, multi-line values) pasted into frontmatter that only supports flat `key: JSON-value` lines; markdown linters reformatting lines.","solutions":["Give every frontmatter line the form `key: value` with a non-empty known key before the colon.","Remove stray prose, blank-formatted, or indented continuation lines from inside the --- block.","Use only the supported frontmatter keys (see FRONTMATTER_KEYS); nested YAML structures are not supported.","Re-save the memory via the library's write path instead of hand-editing to regenerate well-formed frontmatter."],"exampleFix":"// before\n---\ntitle Deploy notes\nschema: 1\n---\n\n// after\n---\ntitle: \"Deploy notes\"\nschema: 1\n---","handlingStrategy":"validation","validationCode":"const lines = frontmatterBlock.split('\\n');\nlines.forEach(l => { if (!/^[^:\\s][^:]*:/.test(l)) throw new Error(`Malformed frontmatter line: ${l}`); });","typeGuard":"const isWellFormedLine = (line) => /^[^:\\s][^:]*:/.test(line);","tryCatchPattern":"try {\n  const parsed = parseMemoryDocument(source, path);\n} catch (err) {\n  if (err.message.includes('Invalid memory frontmatter line')) {\n    const lineNo = findOffendingLine(source); // locate and report\n    console.error('Frontmatter line %d in %s has no `key:` separator.', lineNo, path);\n  } else throw err;\n}","preventionTips":["Always write frontmatter as flat `key: value` lines with a colon.","Don't paste nested YAML (lists, indented keys) into memory frontmatter.","Regenerate documents with the library's writer instead of hand-editing fences."],"tags":["parsing","frontmatter","format"],"backgroundTag":"invalid-argument-format","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"}