{"record":{"id":"4e7402d978527798","repo":"mermaid-js/mermaid","slug":"c4-rel-rel-from-rel-to-references-an","errorCode":null,"errorMessage":"C4 rel \"${rel.from}\" -> \"${rel.to}\" references an unknown shape","messagePattern":"C4 rel \"(.+?)\" -> \"(.+?)\" references an unknown shape","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/mermaid/src/diagrams/c4/c4Renderer.ts","lineNumber":397,"sourceCode":"      rel.label.text = i + ': ' + rel.label.text;\n    }\n    let textLimitWidth = calculateTextWidth(rel.label.text, relConf as TextDimensionConfig);\n    calcC4ShapeTextWH('label', rel, relTextWrap, relConf, textLimitWidth);\n\n    if (rel.techn && rel.techn.text !== '') {\n      textLimitWidth = calculateTextWidth(rel.techn.text, relConf as TextDimensionConfig);\n      calcC4ShapeTextWH('techn', rel, relTextWrap, relConf, textLimitWidth);\n    }\n\n    if (rel.descr && rel.descr.text !== '') {\n      textLimitWidth = calculateTextWidth(rel.descr.text, relConf as TextDimensionConfig);\n      calcC4ShapeTextWH('descr', rel, relTextWrap, relConf, textLimitWidth);\n    }\n\n    const fromNode = getC4ShapeObj(rel.from);\n    const endNode = getC4ShapeObj(rel.to);\n    if (!fromNode || !endNode) {\n      throw new Error(`C4 rel \"${rel.from}\" -> \"${rel.to}\" references an unknown shape`);\n    }\n    const points = getIntersectPoints(fromNode, endNode);\n    if (!points.startPoint || !points.endPoint) {\n      throw new Error(\n        `Could not calculate intersection points for rel \"${rel.from}\" -> \"${rel.to}\"`\n      );\n    }\n    rel.startPoint = points.startPoint;\n    rel.endPoint = points.endPoint;\n  }\n  svgDraw.drawRels(diagram, rels, conf, diagramId);\n};\n\nasync function drawInsideBoundary(\n  diagram: SVG,\n  parentBoundaryAlias: string,\n  parentBounds: Bounds,\n  currentBoundaries: C4Boundary[],","sourceCodeStart":379,"sourceCodeEnd":415,"githubUrl":"https://github.com/mermaid-js/mermaid/blob/d93e9c88c01a599c062ee6a3f1462e3558ac6b90/packages/mermaid/src/diagrams/c4/c4Renderer.ts#L379-L415","documentation":"Thrown by the C4 drawRels function when getC4ShapeObj(rel.from) or getC4ShapeObj(rel.to) returns undefined. Every relationship must reference a C4 shape (Person, System, Component, Container, Boundary, etc.) that has already been declared and is in scope. A miss means the alias does not resolve to any known shape.","triggerScenarios":"A C4 `Rel` directive whose `from` or `to` alias was never declared, was declared in a different (out-of-scope) boundary, or is misspelled. e.g. Rel(personA, systemZ, 'uses') where 'systemZ' is not defined.","commonSituations":"Typo in an alias; referencing a shape declared inside a different boundary that isn't propagated to the current scope; case mismatch (aliases are case-sensitive); renaming a shape without updating its relationships.","solutions":["Verify both `from` and `to` aliases are declared earlier in the C4 DSL.","Check spelling and case — aliases must match exactly.","If a shape is inside a boundary, ensure the relationship is evaluated in a scope where that shape is visible."],"exampleFix":"// before\nPerson(personA, 'A')\nRel(personA, systemZ, 'uses')  // systemZ never declared\n// after\nPerson(personA, 'A')\nSystem(systemZ, 'Z')\nRel(personA, systemZ, 'uses')","handlingStrategy":"validation","validationCode":"function assertRelTargetsExist(rel, resolveAlias) {\n  if (!resolveAlias(rel.from) || !resolveAlias(rel.to)) {\n    throw new Error(`Rel references unknown shape: ${rel.from} -> ${rel.to}`);\n  }\n}","typeGuard":"const relTargetsExist = (rel, resolveAlias) =>\n  Boolean(resolveAlias(rel.from)) && Boolean(resolveAlias(rel.to));","tryCatchPattern":null,"preventionTips":["Declare every Person/System/Container/Component before any Rel that references it.","Treat aliases as case-sensitive; reuse the exact declared alias string."],"tags":["c4","relationship","reference","alias"],"backgroundTag":null,"analyzedSha":"d93e9c88c01a599c062ee6a3f1462e3558ac6b90","analyzedAt":"2026-08-12T06:23:11.304Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}