{"record":{"id":"09d790f1ceac342f","repo":"Egonex-AI/Understand-Anything","slug":"invalid-domain-graph-result-fatal-unknown-e","errorCode":null,"errorMessage":"Invalid domain graph: ${result.fatal ?? \"unknown error\"}","messagePattern":"Invalid domain graph: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"understand-anything-plugin/packages/core/src/persistence/index.ts","lineNumber":189,"sourceCode":"    join(dir, DOMAIN_GRAPH_FILE),\n    JSON.stringify(sanitised, null, 2),\n    \"utf-8\",\n  );\n}\n\nexport function loadDomainGraph(\n  projectRoot: string,\n  options?: { validate?: boolean },\n): KnowledgeGraph | null {\n  const filePath = join(resolveUaDir(projectRoot), DOMAIN_GRAPH_FILE);\n  if (!existsSync(filePath)) return null;\n\n  const data = JSON.parse(readFileSync(filePath, \"utf-8\"));\n\n  if (options?.validate !== false) {\n    const result = validateGraph(data);\n    if (!result.success) {\n      throw new Error(\n        `Invalid domain graph: ${result.fatal ?? \"unknown error\"}`,\n      );\n    }\n    return result.data as KnowledgeGraph;\n  }\n\n  return data as KnowledgeGraph;\n}\n","sourceCodeStart":171,"sourceCodeEnd":198,"githubUrl":"https://github.com/Egonex-AI/Understand-Anything/blob/32944829e7a63a9fa9c55d811d7f98a9530c6a6a/understand-anything-plugin/packages/core/src/persistence/index.ts#L171-L198","documentation":"Thrown by loadDomainGraph, the domain-graph counterpart to loadGraph. It reads .ua/domain-graph.json, parses it, and validates with the same validateGraph; any fatal validation failure is surfaced with the validator's fatal message. Like loadGraph it accepts { validate: false } to bypass.","triggerScenarios":"domain-graph.json is missing required fields, has no valid nodes, lacks project metadata, or is structurally malformed (not an object, truncated JSON, schema-drift from an older version). Distinct from error 3 only in which file is loaded.","commonSituations":"A domain graph produced by a different/older tool version; a partial write after an interrupted domain analysis; manual editing of domain-graph.json; a graph assembled by a custom pipeline that did not match the schema.","solutions":["Regenerate the domain graph via the domain analysis pipeline.","Read with loadDomainGraph(projectRoot, { validate: false }) when you intend to migrate or self-validate the structure.","Inspect the fatal message from validateGraph to pinpoint the offending field and repair it.","Restore domain-graph.json from a backup or version control."],"exampleFix":"// before\nconst dg = loadDomainGraph(projectRoot);\n// after\nconst dg = loadDomainGraph(projectRoot, { validate: false });","handlingStrategy":"validation","validationCode":"import { validateGraph } from '@understand-anything/core/schema';\nconst raw = JSON.parse(readFileSync(domainGraphPath, 'utf-8'));\nif (!validateGraph(raw).success) { /* handle before calling loadDomainGraph */ }","typeGuard":"import { validateGraph } from '@understand-anything/core/schema';\nfunction isValidDomainGraph(data: unknown): data is KnowledgeGraph {\n  return validateGraph(data).success;\n}","tryCatchPattern":"try { const dg = loadDomainGraph(projectRoot); } catch (e) { if (/Invalid domain graph/.test(String((e as Error).message))) { /* regenerate or load with validate:false */ } throw e; }","preventionTips":["Regenerate domain-graph.json via the domain pipeline rather than editing it.","Use { validate: false } only for a self-managed read/migration.","Align tool version with the on-disk domain graph schema."],"tags":["persistence","schema","validation","json","domain-graph"],"backgroundTag":null,"analyzedSha":"32944829e7a63a9fa9c55d811d7f98a9530c6a6a","analyzedAt":"2026-08-12T10:25:44.261Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}