zed-industries/zed · error · RuntimeError

Unknown GUILD_MODE: {mode}

Error message

Unknown GUILD_MODE: {mode}

What it means

main dispatches on the GUILD_MODE environment variable and accepts only "event", "stale", or "weekly"; any other value raises. An unset variable is a different, earlier failure (KeyError from os.environ["GUILD_MODE"]), so this error specifically means set-but-unknown: a typo, wrong case, stray whitespace from yaml, or a mode this script version does not implement.

Source

Thrown at script/github-guild-board.py:726

    GITHUB_HEADERS = {
        "Authorization": f"Bearer {os.environ['GITHUB_TOKEN']}",
        "Accept": "application/vnd.github+json",
        "X-GitHub-Api-Version": "2022-11-28",
    }

    NOW = datetime.now(timezone.utc)

    project_number = int(os.environ["PROJECT_NUMBER"])
    mode = os.environ["GUILD_MODE"]

    if mode == "event":
        run_event(project_number)
    elif mode == "stale":
        run_stale(project_number)
    elif mode == "weekly":
        run_weekly(project_number)
    else:
        raise RuntimeError(f"Unknown GUILD_MODE: {mode}")

View on GitHub (pinned to bc538def45)

Solutions

  1. Set GUILD_MODE to exactly event, stale, or weekly
  2. Strip whitespace when reading: os.environ['GUILD_MODE'].strip()
  3. List the valid modes in the error message so the fix is obvious
  4. Validate all required env (PROJECT_NUMBER, GUILD_MODE) at startup, before any network calls

Example fix

// before
mode = os.environ["GUILD_MODE"]
if mode == "event":
    run_event(project_number)
elif mode == "stale":
    run_stale(project_number)
elif mode == "weekly":
    run_weekly(project_number)
else:
    raise RuntimeError(f"Unknown GUILD_MODE: {mode}")

// after
modes = {"event": run_event, "stale": run_stale, "weekly": run_weekly}
mode = os.environ["GUILD_MODE"].strip()
if mode not in modes:
    raise RuntimeError(f"Unknown GUILD_MODE: {mode!r}; expected one of {sorted(modes)}")
modes[mode](project_number)
Defensive patterns

Strategy: validation

Validate before calling

VALID_GUILD_MODES = {"event", "stale", "weekly"}

def guild_mode_is_valid(mode: str) -> bool:
    return mode.strip() in VALID_GUILD_MODES

Type guard

def is_known_guild_mode(mode: str) -> bool:
    return mode.strip() in {"event", "stale", "weekly"}

Try / catch

mode = os.environ["GUILD_MODE"].strip()
try:
    assert mode in VALID_GUILD_MODES, f"Unknown GUILD_MODE: {mode!r}; expected {sorted(VALID_GUILD_MODES)}"
except AssertionError as exc:
    raise SystemExit(str(exc))

Prevention

When it happens

Trigger: GUILD_MODE=Event (wrong case), GUILD_MODE=daily (never implemented), a trailing newline or space inherited from a workflow yaml expression, or a mode name removed/renamed in a refactor of run_event/run_stale/run_weekly.

Common situations: Workflow updated to a new mode name while the deployed script still expects the old ones; copy-paste typos in CI env blocks; contributors guessing mode names.

Related errors


AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16). Data as JSON: /api/errors/a0885d9bf55e3fb9. Report an issue: GitHub.