rohitg00/ai-engineering-from-scratch · error · ValueError
unknown post_process rule
Error message
unknown post_process rule: {rule} What it means
post_process dispatches model output through a fixed set of named rules (strip_whitespace, lower, extract_letter, extract_code_block, extract_first_line); an unrecognized rule name falls through every branch to the generic guard, indicating a typo or an outdated task spec referencing a rule this runner never implemented.
Solutions
- Check the task spec YAML/JSON for a misspelled post_process rule name
- Extend post_process with the missing rule before using the spec
- Validate rule names against the supported set when loading the task spec
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at phases/19-capstone-projects/70-task-spec-format/code/main.py:262 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of rohitg00/ai-engineering-from-scratch@39ea8a1c6d (2026-08-26).
Data as JSON: /api/errors/5e8d35af95982837.
Report an issue: GitHub.
Appendix: source
Thrown at phases/19-capstone-projects/70-task-spec-format/code/main.py:262
if rule == "strip_whitespace":
return text.strip()
if rule == "lower":
return text.lower()
if rule == "extract_letter":
m = LETTER_RE.search(text)
if m:
return m.group(1)
m2 = LETTER_FALLBACK_RE.search(text)
return m2.group(0) if m2 else ""
if rule == "extract_code_block":
m = CODE_BLOCK_RE.search(text)
return m.group(1) if m else text
if rule == "extract_first_line":
for line in text.splitlines():
if line.strip():
return line.strip()
return ""
raise ValueError(f"unknown post_process rule: {rule}")
def fixture_tasks() -> list[dict]:
return [
{
"task_id": "arith_001",
"category": "arithmetic",
"prompt": "Compute the result.\nQuestion: 17 + 24\nAnswer:",
"targets": ["41"],
"metric_name": "exact_match",
"post_process": "strip_whitespace",
"few_shot_examples": [{"prompt": "Question: 2 + 2\nAnswer:", "completion": "4"}],
"metadata": {"difficulty": "easy"},
},
{
"task_id": "arith_002",
"category": "arithmetic",
"prompt": "Compute the result.\nQuestion: 144 / 12\nAnswer:",View on GitHub (pinned to 39ea8a1c6d)