Hmbown/CodeWhale · error

aliases unknown token

Error message

{name} aliases unknown token {target}

What it means

export-design-tokens.py parses WHALE_*_RGB constants from tokens.rs and resolves aliases. When a constant aliases (group 5) a token name that has not been defined yet, parse_tokens aborts with SystemExit naming the unknown target.

Solutions

  1. Fix the alias target spelling to match an existing WHALE_* token
  2. Define the target token before the aliasing const in tokens.rs
  3. Remove the stale alias if the target token was deleted

Example fix

// before
pub const WHALE_B_RGB: Rgb = WHALE_Aliased_RGB; // unknown
// after
pub const WHALE_B_RGB: Rgb = WHALE_A_RGB; // defined earlier
Defensive patterns

Strategy: validation

Validate before calling

import re
defined = set(re.findall(r"pub const (WHALE_\w+_RGB)", tokens_src))
aliased = set(re.findall(r"WHALE_\w+_RGB:\s*Rgb\s*=\s*(WHALE_\w+_RGB);", tokens_src))
assert aliased <= defined, f"unknown alias targets: {aliased - defined}"

Prevention

When it happens

Trigger: A const like pub const WHALE_X_RGB: Rgb = WHALE_UNDEFINED_RGB; where WHALE_UNDEFINED_RGB was never matched by CONST_RE earlier in the file, or is defined after its use.

Common situations: Renaming or deleting a token in tokens.rs while aliases still reference it; typos in the alias name; forward-referencing a const defined later in the file (parser is order-sensitive).

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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

Appendix: source

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

CONST_RE = re.compile(
    r"^pub const ((?:WHALE|LIGHT)_[A-Z0-9_]+)_RGB: \(u8, u8, u8\) = "
    r"(?:\((\d+), (\d+), (\d+)\)|((?:WHALE|LIGHT)_[A-Z0-9_]+)_RGB);",
    re.MULTILINE,
)



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("_", "-")

View on GitHub (pinned to 433685b202)