{"record":{"id":"d8f44c7f9e265091","repo":"affaan-m/ECC","slug":"unknown-memory-frontmatter-field-in-sourcepath","errorCode":null,"errorMessage":"Unknown memory frontmatter field in ${sourcePath}.","messagePattern":"Unknown memory frontmatter field in (.+?)\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/memory-vault-format.js","lineNumber":230,"sourceCode":"}\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>') {\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.`);","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/memory-vault-format.js#L212-L248","documentation":"parseFrontmatterLine() looks up the serialized key (the text before the colon) in the FRONTMATTER_KEYS map. Only whitelisted field names are accepted; any other key — even a well-formed `key: value` line — is rejected to keep the document schema strict and catch typos.","triggerScenarios":"A frontmatter line with a typo'd or unsupported key such as `titel: \"...\"`, `tags: [...]`, `author: ...`, or a key whose canonical serialized form differs (wrong casing like `Title:`) so it misses the exact map lookup.","commonSituations":"Copying frontmatter from another tool (Jekyll/Hugo style keys like `layout:` or `date:`) into a memory document; renaming a key by hand after a schema change; adding custom metadata fields that the format doesn't allow.","solutions":["Replace the key with one of the supported frontmatter field names (schema, id, title, targetHarnesses, etc. — the keys FRONTMATTER_KEYS recognizes).","Fix casing/typos so the serialized key matches exactly (lookup is exact, not case-insensitive).","Move unsupported metadata into the document body below the closing --- instead of frontmatter.","Regenerate the document with the library's save path to get canonical keys."],"exampleFix":"// before\n---\nschema: 1\nid: \"notes\"\ntitel: \"Deploy notes\"\n---\n\n// after\n---\nschema: 1\nid: \"notes\"\ntitle: \"Deploy notes\"\n---","handlingStrategy":"validation","validationCode":"const ALLOWED = new Set(['schema', 'id', 'title', 'targetHarnesses']);\nfor (const line of frontmatterLines) {\n  const key = line.slice(0, line.indexOf(':')).trim();\n  if (!ALLOWED.has(key)) throw new Error(`Unknown frontmatter key: ${key}`);\n}","typeGuard":"const isKnownFrontmatterKey = (key) => FRONTMATTER_KEYS.has(key);","tryCatchPattern":"try {\n  parseMemoryDocument(source, path);\n} catch (err) {\n  if (err.message.includes('Unknown memory frontmatter field')) {\n    console.error('Fix or remove the unrecognized key in %s; supported keys come from FRONTMATTER_KEYS.', path);\n  } else throw err;\n}","preventionTips":["Copy frontmatter from an existing valid memory document, not from Jekyll/Hugo templates.","Keys are matched exactly — watch casing and typos.","Put custom metadata in the body, not frontmatter."],"tags":["parsing","frontmatter","schema"],"backgroundTag":"unknown-config-key","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"}