{"record":{"id":"352b9eb02d36da87","repo":"squidfunk/mkdocs-material","slug":"unknown-type-type","errorCode":null,"errorMessage":"Unknown type: {type}","messagePattern":"Unknown type: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/overrides/hooks/shortcodes.py","lineNumber":85,"sourceCode":"    # Find and replace all external asset URLs in current page\n    return re.sub(\n        r\"<!-- md:(\\w+)(.*?) -->\",\n        replace, markdown, flags = re.I | re.M\n    )\n\n# -----------------------------------------------------------------------------\n# Helper functions\n# -----------------------------------------------------------------------------\n\n# Create a flag of a specific type\ndef flag(args: str, page: Page, files: Files):\n    type, *_ = args.split(\" \", 1)\n    if   type == \"experimental\":  return _badge_for_experimental(page, files)\n    elif type == \"required\":      return _badge_for_required(page, files)\n    elif type == \"customization\": return _badge_for_customization(page, files)\n    elif type == \"metadata\":      return _badge_for_metadata(page, files)\n    elif type == \"multiple\":      return _badge_for_multiple(page, files)\n    raise RuntimeError(f\"Unknown type: {type}\")\n\n# Create a linkable option\ndef option(type: str):\n    _, *_, name = re.split(r\"[.:]\", type)\n    return f\"[`{name}`](#+{type}){{ #+{type} }}\\n\\n\"\n\n# Create a linkable setting - @todo append them to the bottom of the page\ndef setting(type: str):\n    _, *_, name = re.split(r\"[.*]\", type)\n    return f\"`{name}` {{ #{type} }}\\n\\n[{type}]: #{type}\\n\\n\"\n\n# -----------------------------------------------------------------------------\n\n# Resolve path of file relative to given page - the posixpath always includes\n# one additional level of `..` which we need to remove\ndef _resolve_path(path: str, page: Page, files: Files):\n    path, anchor, *_ = f\"{path}#\".split(\"#\")\n    path = _resolve(files.get_file_from_path(path), page)","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/squidfunk/mkdocs-material/blob/e2136532f40aed98af1f6497c0cc6a3cff9f759b/src/overrides/hooks/shortcodes.py#L67-L103","documentation":"The flag shortcode in the shortcodes hook renders badges for flag types like experimental, required, customization, metadata, and multiple. If the <!-- md:flag ... --> type word matches none of these, flag() raises RuntimeError(\"Unknown type: {type}\"). It enforces the fixed vocabulary of flag badges.","triggerScenarios":"Writing <!-- md:flag optional --> or any flag type not in the implemented list; a typo such as <!-- md:flag experimantal -->; calling flag() directly with an unsupported string.","commonSituations":"Document authors guessing flag names instead of copying from the project's docs conventions; renaming flags in the hook but not updating Markdown; translating docs and translating the flag word too.","solutions":["Use one of the supported types: experimental, required, customization, metadata, multiple.","Correct the spelling in the Markdown file.","If you need a new flag, add an elif branch in flag() with a corresponding badge function."],"exampleFix":"<!-- before -->\n<!-- md:flag deprecated -->\n\n<!-- after -->\n<!-- md:flag experimental -->","handlingStrategy":"validation","validationCode":"VALID_FLAGS = {\"experimental\", \"required\", \"customization\", \"metadata\", \"multiple\"}\nimport re\nfor m in re.finditer(r\"<!-- md:flag (\\w+)\", markdown, re.I | re.M):\n    assert m.group(1).lower() in VALID_FLAGS, f\"Unknown flag type: {m.group(1)}\"","typeGuard":"def is_valid_flag(type: str) -> bool:\n    return type in {\"experimental\", \"required\", \"customization\", \"metadata\", \"multiple\"}","tryCatchPattern":"try:\n    out = on_page_markdown(md, page, config, files)\nexcept RuntimeError as e:\n    if str(e).startswith(\"Unknown type\"):\n        print(\"Flag badge must be one of experimental|required|customization|metadata|multiple:\", e)\n    else:\n        raise","preventionTips":["Use editor autocomplete/snippets for the fixed flag vocabulary.","Spell-check flag words when translating documentation.","Update all Markdown when renaming or adding flag types in the hook.","CI-grep for md:flag usages and validate the type word."],"tags":["python","mkdocs","shortcodes","documentation"],"backgroundTag":"unknown-shortcode","analyzedSha":"e2136532f40aed98af1f6497c0cc6a3cff9f759b","analyzedAt":"2026-08-29T11:20:04.299Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}