can1357/oh-my-pi · error · SystemExit
bad condition {name!r}; expected text|compact|handoff|img-<f
Error message
bad condition {name!r}; expected text|compact|handoff|img-<font>-<variant> What it means
parse_condition validates experimental condition names for snapcompact runs. A condition must be 'text', 'compact', 'handoff', or an image condition 'img-<font>-<variant>' where font is a key in FONTS and variant a key in VARIANTS. Anything else raises SystemExit with this message, aborting the run.
Source
Thrown at packages/metaharness/src/adapters/snapcompact.py:141
path = QA_CACHE / f"{key}.json"
if path.exists() and not fresh:
hit = json.loads(path.read_text())
if hit.get("stop") != "max_tokens" and hit["text"]:
return hit["text"], hit["usage"]
text, usage, stop = complete(api_key, model, messages, **kw)
if stop == "max_tokens":
print(f" WARN truncated response (stop=max_tokens), not cached: {key}")
else:
path.write_text(json.dumps({"text": text, "usage": usage, "stop": stop}))
return text, usage
def parse_condition(name: str) -> dict:
if name in ("text", "compact", "handoff"):
return {"name": name, "kind": name}
m = re.fullmatch(r"img-([a-z0-9]+)-([a-z-]+)", name)
if not m or m.group(1) not in FONTS or m.group(2) not in VARIANTS:
raise SystemExit(
f"bad condition {name!r}; expected text|compact|handoff|img-<font>-<variant>"
)
return {
"name": name,
"kind": "image",
"font": FONTS[m.group(1)],
"variant": m.group(2),
}
def run_chunk(cond: dict, start: int, end: int, ctx_args: dict) -> list[dict]:
"""Execute one (condition, chunk) task; returns per-question records."""
args, flow, paras, offsets, api_key = (
ctx_args["args"],
ctx_args["flow"],
ctx_args["paras"],
ctx_args["offsets"],
ctx_args["api_key"],View on GitHub (pinned to 9690622007)
Solutions
- Use one of the exact names: text, compact, handoff.
- For image conditions use img-<font>-<variant> with keys that exist in FONTS and VARIANTS in snapcompact.py — check those dicts for valid values.
- Fix typos and case (names are lowercase; regex is r'img-([a-z0-9]+)-([a-z-]+)').
- If a new font/variant is genuinely needed, register it in FONTS/VARIANTS first.
Example fix
# before python snapcompact.py --condition img-nosuchfont-bold # after python snapcompact.py --condition img-<registered-font>-<registered-variant> # or: text|compact|handoff
Defensive patterns
Strategy: validation
Validate before calling
def valid_condition(name):
if name in ("text", "compact", "handoff"):
return True
import re
m = re.fullmatch(r"img-([a-z0-9]+)-([a-z-]+)", name)
return bool(m and m.group(1) in FONTS and m.group(2) in VARIANTS) Try / catch
try:
cond = parse_condition(name)
except SystemExit as e:
print(f"{e}; valid: text|compact|handoff or img-<font>-<variant> with fonts={list(FONTS)} variants={list(VARIANTS)}")
sys.exit(2) Prevention
- Keep condition names lowercase.
- Consult FONTS/VARIANTS keys before composing img- conditions.
- Build the condition list programmatically from FONTS/VARIANTS instead of typing names.
When it happens
Trigger: Passing a condition name like 'image', 'img-foo-bar' (unknown font/variant), 'compact-handoff', or a typo'd condition on the command line; the regex or the FONTS/VARIANTS membership checks fail.
Common situations: CLI typo when launching experiments; inventing a variant/font key not registered in FONTS/VARIANTS; case differences (e.g. 'IMG-...' since the regex is lowercase-only).
Understand the failure class
Background: Invalid option value errors: "must be one of", "is not a valid", and "only allows" failures explained — this error's family across 23 libraries.
Related errors
- invalid {} argument: {}
- invalid Zero increment value: {}
- --agents must be a positive integer
- --trusted-extension requires a non-empty, non-flag value
- --trusted-extension requires an absolute path: ${trustedPath
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/ca051a3f331cfad3.
Report an issue: GitHub.