{"record":{"id":"2b711df5bfce194a","repo":"Hmbown/CodeWhale","slug":"no-whale-rgb-consts-found-in-tokens-rs","errorCode":null,"errorMessage":"no WHALE_*_RGB consts found in {TOKENS_RS}","messagePattern":"no WHALE_\\*_RGB consts found in (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/export-design-tokens.py","lineNumber":51,"sourceCode":"\n\n\ndef parse_tokens(text: str) -> list[tuple[str, tuple[int, int, int] | str]]:\n    \"\"\"Return [(NAME, (r, g, b) | alias-NAME)] in source order.\"\"\"\n    tokens: list[tuple[str, tuple[int, int, int] | str]] = []\n    known: set[str] = set()\n    for m in CONST_RE.finditer(text):\n        name = m.group(1)\n        if m.group(5) is not None:\n            target = m.group(5)\n            if target not in known:\n                raise SystemExit(f\"{name} aliases unknown token {target}\")\n            tokens.append((name, target))\n        else:\n            tokens.append((name, (int(m.group(2)), int(m.group(3)), int(m.group(4)))))\n        known.add(name)\n    if not tokens:\n        raise SystemExit(f\"no WHALE_*_RGB consts found in {TOKENS_RS}\")\n    return tokens\n\n\ndef css_name(name: str) -> str:\n    \"\"\"`WHALE_*` exports as `--whale-*`; the Blue Stage light preset's\n    `LIGHT_*` consts export as `--light-*` so the website's paper surface can\n    reference the same light-mode ink and border values the TUI ships.\"\"\"\n    if name.startswith(\"LIGHT_\"):\n        return \"--light-\" + name.removeprefix(\"LIGHT_\").lower().replace(\"_\", \"-\")\n    return \"--whale-\" + name.removeprefix(\"WHALE_\").lower().replace(\"_\", \"-\")\n\n\ndef render_css(tokens) -> str:\n    lines = [\n        f\"/* generated from {SOURCE_LABEL} — do not edit */\",\n        \"/* regenerate: scripts/export-design-tokens.py (in the codewhale repo) */\",\n        \":root {\",\n    ]","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/export-design-tokens.py#L33-L69","documentation":"parse_tokens() requires at least one WHALE_*_RGB constant match in the tokens source file. If CONST_RE finds nothing, it exits with this message naming TOKENS_RS, because the exporter has nothing to convert.","triggerScenarios":"Running the exporter when tokens.rs contains no constants matching the WHALE_*_RGB pattern — file moved/renamed, pattern changed, or file empty.","commonSituations":"Refactoring tokens.rs to a different naming scheme or file layout; wrong repo root when running the script (TOKENS_RS path no longer exists or is empty); regex drifted from the Rust source format.","solutions":["Confirm TOKENS_RS points at the right file containing pub const WHALE_*_RGB definitions","Restore the WHALE_*_RGB naming pattern or update CONST_RE to match the new format","Run the script from the repo root so the relative tokens.rs path resolves"],"exampleFix":"// before (tokens.rs)\nconst COLORS: [(u8,u8,u8); 1] = [(1,2,3)];\n// after\npub const WHALE_BLUE_RGB: (u8, u8, u8) = (1, 2, 3);","handlingStrategy":"validation","validationCode":"import re\nsrc = open(tokens_rs).read()\nassert re.search(r\"WHALE_\\w+_RGB\", src), \"no WHALE_*_RGB consts found in tokens.rs\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run the exporter from the repo root","Keep the WHALE_*_RGB naming convention stable","Update CONST_RE whenever the tokens source format changes"],"tags":["python","codegen","design-tokens"],"backgroundTag":"empty-result-set","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}