{"record":{"id":"027223da398fee1c","repo":"666ghj/MiroFish","slug":"unsupported-svg-theme","errorCode":null,"errorMessage":"unsupported SVG theme","messagePattern":"unsupported SVG theme","errorType":"exception","errorClass":"StarHistoryError","httpStatus":null,"severity":"error","filePath":"scripts/star_history.py","lineNumber":853,"sourceCode":"            f\"{_format_float(control1_x)},{_format_float(control1_y)} \"\n            f\"{_format_float(control2_x)},{_format_float(control2_y)} \"\n            f\"{_format_float(x1)},{_format_float(y1)}\"\n        )\n    return \"\".join(commands)\n\n\ndef render_svg(state: Mapping[str, Any], theme: str) -> bytes:\n    \"\"\"Render the dependency-free Star History-compatible SVG.\n\n    The visual contract is a clean-room Python reimplementation of the MIT\n    licensed ``star-history/star-history`` renderer behavior reviewed for this\n    setup. No narayann7 JavaScript, npm package, or runtime dependency is\n    vendored or executed here.\n    \"\"\"\n\n    validate_state(state)\n    if theme not in {\"light\", \"dark\"}:\n        raise StarHistoryError(\"unsupported SVG theme\")\n\n    width = 800.0\n    height = 533.333\n    plot_left = 70.0\n    plot_top = 60.0\n    plot_width = 700.0\n    plot_height = 423.333\n    plot_bottom = plot_top + plot_height\n\n    if theme == \"light\":\n        background = \"#ffffff\"\n        foreground = \"#000000\"\n        legend_background = \"#ffffff\"\n        line_color = \"#dd4528\"\n    else:\n        background = \"#0d1117\"\n        foreground = \"#ffffff\"\n        legend_background = \"#0d1117\"","sourceCodeStart":835,"sourceCodeEnd":871,"githubUrl":"https://github.com/666ghj/MiroFish/blob/b5b53acc57189a4a42e44a23e149dc655c98fe82/scripts/star_history.py#L835-L871","documentation":"Raised by `render_svg(state, theme)` at scripts/star_history.py:853 when `theme` is not exactly `\"light\"` or `\"dark\"`. The renderer ships two hand-tuned palettes (background/foreground colors etc.) and deliberately rejects anything else, including case variants and locale names, before `validate_state` output is drawn.","triggerScenarios":"Calling `render_svg(state, theme)` with e.g. `\"Dark\"`, `\"dark-mode\"`, `\"\"`, `None`, or a theme read from config/CLI argv without normalization. The check is a set membership test `theme not in {\"light\", \"dark\"}` — case-sensitive.","commonSituations":"Wrapping the script in CI or a badge service that passes `?theme=Dark` or `theme=default`; wiring the theme from an environment variable with different casing; new callers assuming arbitrary theme strings are supported.","solutions":["Pass exactly `\"light\"` or `\"dark\"` (lowercase, ASCII).","Normalize input before calling: `theme = theme.strip().lower() if isinstance(theme, str) else \"light\"` restricted to the two allowed values.","If a 'default' theme is requested, map it to \"light\" at the call site — the renderer has no default branch by design.","Check the caller that constructs the theme string (CLI flag parser, HTTP query param) and constrain it to a choices=[\"light\",\"dark\"] argument."],"exampleFix":"# before\nsvg = render_svg(state, theme=request.args.get(\"theme\", \"default\"))  # raises\n\n# after\nTHEMES = {\"light\", \"dark\"}\ntheme = request.args.get(\"theme\", \"light\").strip().lower()\nif theme not in THEMES:\n    theme = \"light\"\nsvg = render_svg(state, theme=theme)","handlingStrategy":"validation","validationCode":"ALLOWED_THEMES = {\"light\", \"dark\"}\ntheme = theme if theme in ALLOWED_THEMES else \"light\"  # or reject explicitly\nsvg = render_svg(state, theme)","typeGuard":"def is_supported_theme(value: object) -> TypeGuard[str]:\n    return isinstance(value, str) and value in {\"light\", \"dark\"}","tryCatchPattern":"try:\n    svg = render_svg(state, theme)\nexcept StarHistoryError as exc:\n    if \"unsupported SVG theme\" in str(exc):\n        svg = render_svg(state, \"light\")  # explicit fallback choice\n    else:\n        raise","preventionTips":["Constrain theme at the input boundary: argparse choices=[\"light\", \"dark\"] or an enum in config.","Normalize casing/whitespace before calling render_svg — the check is exact-match and case-sensitive.","Document the two supported values wherever the theme parameter is exposed (badge URLs, env vars)."],"tags":["svg","rendering","theme","input-validation"],"backgroundTag":null,"analyzedSha":"b5b53acc57189a4a42e44a23e149dc655c98fe82","analyzedAt":"2026-08-14T22:29:33.146Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}