{"record":{"id":"ca051a3f331cfad3","repo":"can1357/oh-my-pi","slug":"bad-condition-name-r-expected-text-compact-hand","errorCode":null,"errorMessage":"bad condition {name!r}; expected text|compact|handoff|img-<font>-<variant>","messagePattern":"bad condition (.+?); expected text\\|compact\\|handoff\\|img-<font>-<variant>","errorType":"validation","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"packages/metaharness/src/adapters/snapcompact.py","lineNumber":141,"sourceCode":"    path = QA_CACHE / f\"{key}.json\"\n    if path.exists() and not fresh:\n        hit = json.loads(path.read_text())\n        if hit.get(\"stop\") != \"max_tokens\" and hit[\"text\"]:\n            return hit[\"text\"], hit[\"usage\"]\n    text, usage, stop = complete(api_key, model, messages, **kw)\n    if stop == \"max_tokens\":\n        print(f\"  WARN truncated response (stop=max_tokens), not cached: {key}\")\n    else:\n        path.write_text(json.dumps({\"text\": text, \"usage\": usage, \"stop\": stop}))\n    return text, usage\n\n\ndef parse_condition(name: str) -> dict:\n    if name in (\"text\", \"compact\", \"handoff\"):\n        return {\"name\": name, \"kind\": name}\n    m = re.fullmatch(r\"img-([a-z0-9]+)-([a-z-]+)\", name)\n    if not m or m.group(1) not in FONTS or m.group(2) not in VARIANTS:\n        raise SystemExit(\n            f\"bad condition {name!r}; expected text|compact|handoff|img-<font>-<variant>\"\n        )\n    return {\n        \"name\": name,\n        \"kind\": \"image\",\n        \"font\": FONTS[m.group(1)],\n        \"variant\": m.group(2),\n    }\n\n\ndef run_chunk(cond: dict, start: int, end: int, ctx_args: dict) -> list[dict]:\n    \"\"\"Execute one (condition, chunk) task; returns per-question records.\"\"\"\n    args, flow, paras, offsets, api_key = (\n        ctx_args[\"args\"],\n        ctx_args[\"flow\"],\n        ctx_args[\"paras\"],\n        ctx_args[\"offsets\"],\n        ctx_args[\"api_key\"],","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/metaharness/src/adapters/snapcompact.py#L123-L159","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","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."],"exampleFix":"# before\npython snapcompact.py --condition img-nosuchfont-bold\n# after\npython snapcompact.py --condition img-<registered-font>-<registered-variant>  # or: text|compact|handoff","handlingStrategy":"validation","validationCode":"def valid_condition(name):\n    if name in (\"text\", \"compact\", \"handoff\"):\n        return True\n    import re\n    m = re.fullmatch(r\"img-([a-z0-9]+)-([a-z-]+)\", name)\n    return bool(m and m.group(1) in FONTS and m.group(2) in VARIANTS)","typeGuard":null,"tryCatchPattern":"try:\n    cond = parse_condition(name)\nexcept SystemExit as e:\n    print(f\"{e}; valid: text|compact|handoff or img-<font>-<variant> with fonts={list(FONTS)} variants={list(VARIANTS)}\")\n    sys.exit(2)","preventionTips":["Keep condition names lowercase.","Consult FONTS/VARIANTS keys before composing img- conditions.","Build the condition list programmatically from FONTS/VARIANTS instead of typing names."],"tags":["cli","validation","argument-format"],"backgroundTag":"invalid-option-value","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}