{"record":{"id":"d2e4ce1bb58a9764","repo":"mermaid-js/mermaid","slug":"unknown-set-identifier-unknown-join","errorCode":null,"errorMessage":"unknown set identifier: ${unknown.join(', ')}","messagePattern":"unknown set identifier: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/mermaid/src/diagrams/venn/vennDB.ts","lineNumber":84,"sourceCode":"  for (const [key, value] of data) {\n    styles[key] = normalizeStyleValue(value) ?? value;\n  }\n  styleEntries.push({ targets, styles });\n};\n\nexport const getStyleData = () => {\n  return styleEntries;\n};\n\nconst normalizeIdentifierList = (identifierList: string[]) => {\n  return identifierList.map((identifier) => normalizeText(identifier));\n};\n\nexport const validateUnionIdentifiers: VennDB['validateUnionIdentifiers'] = (identifierList) => {\n  const normalized = normalizeIdentifierList(identifierList);\n  const unknown = normalized.filter((identifier) => !knownSets.has(identifier));\n  if (unknown.length > 0) {\n    throw new Error(`unknown set identifier: ${unknown.join(', ')}`);\n  }\n};\n\nexport const getTextData = () => {\n  return textNodes;\n};\n\nexport const getCurrentSets: VennDB['getCurrentSets'] = () => currentSets;\nexport const getIndentMode: VennDB['getIndentMode'] = () => indentMode;\nexport const setIndentMode: VennDB['setIndentMode'] = (enabled) => {\n  indentMode = enabled;\n};\n\nconst DEFAULT_VENN_CONFIG: Required<VennDiagramConfig> = DEFAULT_CONFIG.venn;\n\nfunction getConfig(): Required<VennDiagramConfig> {\n  return cleanAndMerge(DEFAULT_VENN_CONFIG, commonGetConfig().venn);\n}","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/mermaid-js/mermaid/blob/d93e9c88c01a599c062ee6a3f1462e3558ac6b90/packages/mermaid/src/diagrams/venn/vennDB.ts#L66-L102","documentation":"Venn sets are first registered as singletons: addSubsetData with one identifier adds that id to knownSets. validateUnionIdentifiers() then checks that every identifier referenced by a union/intersection set was previously declared as a singleton; any id not in knownSets is reported back as unknown.","triggerScenarios":"Defining an intersection/union set (two or more identifiers) that references an identifier never declared on its own, e.g. `A & B` where `B` was never a standalone `A` set. Case/quote differences also count as unknown because identifiers are normalised (trimmed, quotes stripped) before comparison.","commonSituations":"Typing a set name differently between its singleton declaration and the union; reordering so the union appears before the singleton; deleting a singleton but leaving a union that uses it; quoting inconsistently (`\"A\"` vs `A`).","solutions":["Declare each referenced set as a singleton (one identifier) before using it in a union/intersection.","Match identifier spelling exactly, including the same quoting, between singleton and union.","Remove unions that reference sets you no longer declare.","Define singletons first, then unions, to guarantee registration order."],"exampleFix":"// before — B referenced but never declared alone\nA: 10\nA|B: 5\n\n// after\nA: 10\nB: 8\nA|B: 5","handlingStrategy":"validation","validationCode":"// Collect declared singleton sets, then verify unions reference only those\nconst known = new Set<string>();\nsingletons.forEach(s => known.add(normalize(s)));\nfor (const u of unions) {\n  for (const id of u.ids) {\n    if (!known.has(normalize(id))) throw new Error(`unknown set identifier: ${id}`);\n  }\n}\n// normalize = trim and strip surrounding quotes","typeGuard":"const isUnknownSetError = (e): boolean =>\n  e instanceof Error && /^unknown set identifier:/.test(e.message);","tryCatchPattern":"try {\n  vennDB.validateUnionIdentifiers(ids);\n} catch (e) {\n  if (e instanceof Error && /^unknown set identifier:/.test(e.message)) {\n    // extract the listed ids and ensure each is declared as a singleton\n  } else { throw e; }\n}","preventionTips":["Declare every set as a singleton before referencing it in a union.","Keep identifier spelling/quotes consistent across declarations and unions.","Order definitions: singletons first, then unions."],"tags":["venn","set-identifier","validation","ordering"],"backgroundTag":null,"analyzedSha":"d93e9c88c01a599c062ee6a3f1462e3558ac6b90","analyzedAt":"2026-08-12T06:23:11.304Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}