{"record":{"id":"3e1f1944bb7af0ee","repo":"mermaid-js/mermaid","slug":"invalid-icon-name-iconname","errorCode":null,"errorMessage":"Invalid icon name: ${iconName}","messagePattern":"Invalid icon name: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/mermaid/src/rendering-util/icons.ts","lineNumber":51,"sourceCode":"        'Invalid icon loader. Must have a \"name\" property with non-empty string value.'\n      );\n    }\n    log.debug('Registering icon pack:', iconLoader.name);\n    if ('loader' in iconLoader) {\n      loaderStore.set(iconLoader.name, iconLoader.loader);\n    } else if ('icons' in iconLoader) {\n      iconsStore.set(iconLoader.name, iconLoader.icons);\n    } else {\n      log.error('Invalid icon loader:', iconLoader);\n      throw new Error('Invalid icon loader. Must have either \"icons\" or \"loader\" property.');\n    }\n  }\n};\n\nconst getRegisteredIconData = async (iconName: string, fallbackPrefix?: string) => {\n  const data = stringToIcon(iconName, true, fallbackPrefix !== undefined);\n  if (!data) {\n    throw new Error(`Invalid icon name: ${iconName}`);\n  }\n  const prefix = data.prefix || fallbackPrefix;\n  if (!prefix) {\n    throw new Error(`Icon name must contain a prefix: ${iconName}`);\n  }\n  let icons = iconsStore.get(prefix);\n  if (!icons) {\n    const loader = loaderStore.get(prefix);\n    if (!loader) {\n      throw new Error(`Icon set not found: ${data.prefix}`);\n    }\n    try {\n      const loaded = await loader();\n      icons = { ...loaded, prefix };\n      iconsStore.set(prefix, icons);\n    } catch (e) {\n      log.error(e);\n      throw new Error(`Failed to load icon set: ${data.prefix}`);","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/mermaid-js/mermaid/blob/d93e9c88c01a599c062ee6a3f1462e3558ac6b90/packages/mermaid/src/rendering-util/icons.ts#L33-L69","documentation":"Thrown by getRegisteredIconData when @iconify/utils' stringToIcon(iconName, true, allowOptionalPrefix) returns null/undefined — meaning the raw icon name string cannot be parsed into a {prefix, name} pair at all. This is a malformed-name failure, distinct from a missing prefix (103). It happens during icon lookup from getIconSVG and isIconAvailable (where it is swallowed and returns false).","triggerScenarios":"Passing an icon name that is not a valid iconify identifier: empty string, whitespace-only, names containing only a colon, names with invalid characters, or `:` with empty segments. e.g. getIconSVG(':') , getIconSVG('') , getIconSVG(':::'). stringToIcon's second arg is `true` (validate), so structurally broken strings return null.","commonSituations":"Dynamic icon name construction that yields empty segments (e.g. `${prefix}:${name}` where one var is undefined), reading icon names from user input without sanitization, or copy/paste with stray characters. In diagrams, an icon: directive whose value fails to parse surfaces here when the renderer resolves it.","solutions":["Ensure icon names follow the iconify convention `prefix:name` (or `prefix-name`) with both segments non-empty, e.g. `logos:react`.","Sanitize/validate the icon string before it reaches rendering: trim it and confirm it matches /^[a-z0-9-]+:[a-z0-9-]+$/i.","If using a fallbackPrefix via config, still supply a real icon name segment — the fallback only fills the prefix, not the name.","Use the isIconAvailable() helper to probe without throwing; it wraps getRegisteredIconData in try/catch and returns false."],"exampleFix":"// before\ngetIconSVG(':', {});\n// after\ngetIconSVG('logos:javascript', { fallbackPrefix: 'logos' });","handlingStrategy":"validation","validationCode":"const ICON_NAME_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*:[a-z0-9]+(?:-[a-z0-9]+)*$/i;\nfunction isValidIconName(s: string): boolean { return typeof s === 'string' && ICON_NAME_RE.test(s.trim()); }\nif (!isValidIconName(name)) throw new Error(`bad icon name: ${name}`);","typeGuard":"function isIconName(s: unknown): s is string {\n  return typeof s === 'string' && s.includes(':') && s.split(':').every((p) => p.trim().length > 0);\n}","tryCatchPattern":"try { await getIconSVG(name, opts); } catch (e) { if (/Invalid icon name/.test(String(e))) return fallbackSvg; throw e; }","preventionTips":["Always use the `prefix:name` form.","Sanitize user-supplied icon strings before rendering.","Prefer isIconAvailable() to probe names without throwing."],"tags":["icons","validation","iconify","rendering"],"backgroundTag":null,"analyzedSha":"d93e9c88c01a599c062ee6a3f1462e3558ac6b90","analyzedAt":"2026-08-12T06:23:11.304Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}