{"record":{"id":"9563e745df911592","repo":"affaan-m/ECC","slug":"memory-document-sourcepath-is-missing-fields","errorCode":null,"errorMessage":"Memory document ${sourcePath} is missing fields: ${missing.join(', ')}.","messagePattern":"Memory document (.+?) is missing fields: (.+?)\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/memory-vault-format.js","lineNumber":274,"sourceCode":"  const closingMarker = /\\r?\\n---(?=\\r?\\n|$)/.exec(remainder);\n  if (!closingMarker) {\n    throw new Error(`Memory document ${sourcePath} has no closing frontmatter marker.`);\n  }\n\n  const frontmatterSource = remainder.slice(0, closingMarker.index);\n  const parsed = frontmatterSource.split(/\\r?\\n/).reduce((state, line) => {\n    const next = parseFrontmatterLine(line, sourcePath, state.seen);\n    return {\n      values: { ...state.values, [next.objectKey]: next.value },\n      seen: new Set([...state.seen, next.objectKey]),\n    };\n  }, { values: {}, seen: new Set() });\n\n  const missing = FRONTMATTER_FIELDS\n    .map(([, objectKey]) => objectKey)\n    .filter(objectKey => !parsed.seen.has(objectKey));\n  if (missing.length > 0) {\n    throw new Error(`Memory document ${sourcePath} is missing fields: ${missing.join(', ')}.`);\n  }\n\n  const afterMarker = remainder.slice(closingMarker.index + closingMarker[0].length);\n  const body = afterMarker.replace(/^\\r?\\n/, '').replace(/\\r?\\n$/, '');\n  return normalizeMemory({ ...parsed.values, body });\n}\n\nfunction findPotentialSecrets(value) {\n  const text = typeof value === 'string' ? value : '';\n  return SECRET_PATTERNS\n    .filter(item => item.pattern.test(text))\n    .map(item => item.label)\n    .filter((label, index, labels) => labels.indexOf(label) === index);\n}\n\nmodule.exports = {\n  MAX_BODY_BYTES,\n  MAX_DOCUMENT_BYTES,","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/lib/memory-vault-format.js#L256-L292","documentation":"Thrown by parseMemoryDocument() after parsing all frontmatter lines, when one or more of the 13 required FRONTMATTER_FIELDS (schema, id, title, kind, scope, trust, status, source_harness, target_harnesses, tags, links, created_at, updated_at) was not seen. The error message lists the missing object keys. Required-field enforcement prevents silent partial documents from entering the vault.","triggerScenarios":"A hand-written file that omits 'trust:' (an easy-to-forget field). A migration from a v0 schema that lacked tags/links. An editor that dropped a field with an empty value. A copy-paste that lost the last line. AI agent that produced an incomplete document.","commonSituations":"Authoring memories by hand without a template. Ad-hoc export from another tool that did not emit all fields. Refactor that removed a field by accident. Merge conflict where one side deleted a line.","solutions":["Read the error message — it lists exactly which object keys are missing (e.g. 'trust, links').","Add each missing field with a valid JSON value: trust: \"unreviewed\", links: [].","Author new files via saveMemory() so every field is populated by normalizeSaveInput().","Keep a template file with all 13 fields and copy it as the starting point."],"exampleFix":"// before — missing trust, links, tags\n---\nschema: \"ecc.memory.v1\"\nid: \"mem_x\"\ntitle: \"x\"\nkind: \"note\"\nscope: \"project\"\nstatus: \"active\"\nsource_harness: \"claude\"\ntarget_harnesses: [\"all\"]\ncreated_at: \"2024-08-12T00:00:00.000Z\"\nupdated_at: \"2024-08-12T00:00:00.000Z\"\n---\n\n// after — add the missing fields\ntrust: \"unreviewed\"\ntags: []\nlinks: []","handlingStrategy":"validation","validationCode":"const REQUIRED = ['schema','id','title','kind','scope','trust','status','source_harness','target_harnesses','tags','links','created_at','updated_at'];\nconst present = new Set(parsedFrontmatterLines.map(l => l.slice(0, l.indexOf(':')).trim()));\nconst missing = REQUIRED.filter(k => !present.has(k));\nif (missing.length) throw new Error(`missing frontmatter fields: ${missing.join(', ')}`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep a template file with all 13 fields populated and copy it as a starting point.","Use saveMemory() to author — it fills every required field via normalizeSaveInput().","Treat missing-field errors during read as corruption; rebuild the file from the canonical source."],"tags":["parsing","frontmatter","validation","memory-vault","required-field"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}