Hmbown/CodeWhale · error

no WHALE_*_RGB consts found in

Error message

no WHALE_*_RGB consts found in {TOKENS_RS}

What it means

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.

Solutions

  1. Confirm TOKENS_RS points at the right file containing pub const WHALE_*_RGB definitions
  2. Restore the WHALE_*_RGB naming pattern or update CONST_RE to match the new format
  3. Run the script from the repo root so the relative tokens.rs path resolves

Example fix

// before (tokens.rs)
const COLORS: [(u8,u8,u8); 1] = [(1,2,3)];
// after
pub const WHALE_BLUE_RGB: (u8, u8, u8) = (1, 2, 3);
Defensive patterns

Strategy: validation

Validate before calling

import re
src = open(tokens_rs).read()
assert re.search(r"WHALE_\w+_RGB", src), "no WHALE_*_RGB consts found in tokens.rs"

Prevention

When it happens

Trigger: Running the exporter when tokens.rs contains no constants matching the WHALE_*_RGB pattern — file moved/renamed, pattern changed, or file empty.

Common situations: 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.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/2b711df5bfce194a. Report an issue: GitHub.

Appendix: source

Thrown at scripts/export-design-tokens.py:51



def parse_tokens(text: str) -> list[tuple[str, tuple[int, int, int] | str]]:
    """Return [(NAME, (r, g, b) | alias-NAME)] in source order."""
    tokens: list[tuple[str, tuple[int, int, int] | str]] = []
    known: set[str] = set()
    for m in CONST_RE.finditer(text):
        name = m.group(1)
        if m.group(5) is not None:
            target = m.group(5)
            if target not in known:
                raise SystemExit(f"{name} aliases unknown token {target}")
            tokens.append((name, target))
        else:
            tokens.append((name, (int(m.group(2)), int(m.group(3)), int(m.group(4)))))
        known.add(name)
    if not tokens:
        raise SystemExit(f"no WHALE_*_RGB consts found in {TOKENS_RS}")
    return tokens


def css_name(name: str) -> str:
    """`WHALE_*` exports as `--whale-*`; the Blue Stage light preset's
    `LIGHT_*` consts export as `--light-*` so the website's paper surface can
    reference the same light-mode ink and border values the TUI ships."""
    if name.startswith("LIGHT_"):
        return "--light-" + name.removeprefix("LIGHT_").lower().replace("_", "-")
    return "--whale-" + name.removeprefix("WHALE_").lower().replace("_", "-")


def render_css(tokens) -> str:
    lines = [
        f"/* generated from {SOURCE_LABEL} — do not edit */",
        "/* regenerate: scripts/export-design-tokens.py (in the codewhale repo) */",
        ":root {",
    ]

View on GitHub (pinned to 433685b202)