{"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/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/lib/memory-vault-format.js#L212-L248","documentation":"Thrown by parseFrontmatterLine() when the key before the ':' is not one of the 13 known serialized keys (schema, id, title, kind, scope, trust, status, source_harness, target_harnesses, tags, links, created_at, updated_at). Unknown keys are rejected rather than ignored to surface typos and schema drift — otherwise a misspelled 'tittle:' would silently drop the title.","triggerScenarios":"A memory file with 'author: ...' (no such field), 'title_text: \"x\"', 'created: \"...\"' instead of 'created_at:', 'sourceHarness: \"x\"' using the camelCase object key instead of the snake_case serialized key, or 'source-harness:' with a hyphen instead of underscore.","commonSituations":"Hand-edited file where the user guessed the field name. AI agent wrote the camelCase key from the JS object instead of the snake_case wire key. Documentation example that used a slightly different field name. Future field added by a newer version that this parser does not know about.","solutions":["Cross-check the offending key against FRONTMATTER_FIELDS in memory-vault-format.js.","Use snake_case for serialized keys: source_harness, target_harnesses, created_at, updated_at.","Regenerate the document with serializeMemoryDocument() to get the canonical keys.","If you intended to extend the schema, that requires changing MEMORY_SCHEMA_VERSION and updating the parser — do not add fields unilaterally."],"exampleFix":"// before\n---\nsourceHarness: \"claude\"\ncreatedAt: \"2024-08-12T00:00:00.000Z\"\n---\n\n// after\n---\nsource_harness: \"claude\"\ncreated_at: \"2024-08-12T00:00:00.000Z\"\n---","handlingStrategy":"validation","validationCode":"const { FRONTMATTER_FIELDS } = require('./scripts/lib/memory-vault-format'); // if exported\nconst KNOWN = new Set(['schema','id','title','kind','scope','trust','status','source_harness','target_harnesses','tags','links','created_at','updated_at']);\nObject.keys(parsed).forEach(k => {\n  if (!KNOWN.has(k)) throw new Error(`unknown frontmatter field: ${k}`);\n});","typeGuard":"const KNOWN = new Set(['schema','id','title','kind','scope','trust','status','source_harness','target_harnesses','tags','links','created_at','updated_at']);\nfunction isKnownFrontmatterKey(key): key is string {\n  return KNOWN.has(key);\n}","tryCatchPattern":null,"preventionTips":["Always use snake_case serialized keys, not the camelCase object keys.","Regenerate documents via serializeMemoryDocument() to get canonical keys.","Schema extensions require bumping MEMORY_SCHEMA_VERSION — do not add fields ad hoc."],"tags":["parsing","frontmatter","validation","memory-vault","schema"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}