{"record":{"id":"4e0df4fac1084cc5","repo":"shareAI-lab/learn-claude-code","slug":"invalid-status-status","errorCode":null,"errorMessage":"Invalid status: {status}","messagePattern":"Invalid status: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agents/s07_task_system.py","lineNumber":84,"sourceCode":"\n    def create(self, subject: str, description: str = \"\") -> str:\n        task = {\n            \"id\": self._next_id, \"subject\": subject, \"description\": description,\n            \"status\": \"pending\", \"blockedBy\": [], \"owner\": \"\",\n        }\n        self._save(task)\n        self._next_id += 1\n        return json.dumps(task, indent=2, ensure_ascii=False)\n\n    def get(self, task_id: int) -> str:\n        return json.dumps(self._load(task_id), indent=2, ensure_ascii=False)\n\n    def update(self, task_id: int, status: str = None,\n               add_blocked_by: list = None, remove_blocked_by: list = None) -> str:\n        task = self._load(task_id)\n        if status:\n            if status not in (\"pending\", \"in_progress\", \"completed\"):\n                raise ValueError(f\"Invalid status: {status}\")\n            task[\"status\"] = status\n            if status == \"completed\":\n                self._clear_dependency(task_id)\n        if add_blocked_by:\n            task[\"blockedBy\"] = list(set(task[\"blockedBy\"] + add_blocked_by))\n        if remove_blocked_by:\n            task[\"blockedBy\"] = [x for x in task[\"blockedBy\"] if x not in remove_blocked_by]\n        self._save(task)\n        return json.dumps(task, indent=2, ensure_ascii=False)\n\n    def _clear_dependency(self, completed_id: int):\n        \"\"\"Remove completed_id from all other tasks' blockedBy lists.\"\"\"\n        for f in self.dir.glob(\"task_*.json\"):\n            task = json.loads(f.read_text())\n            if completed_id in task.get(\"blockedBy\", []):\n                task[\"blockedBy\"].remove(completed_id)\n                self._save(task)\n","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/shareAI-lab/learn-claude-code/blob/985456f4adea6f4df8fbad4112245dbd97444eae/agents/s07_task_system.py#L66-L102","documentation":"Raised by TaskManager.update() in agents/s07_task_system.py:84 when the `status` argument is truthy but not one of \"pending\", \"in_progress\", \"completed\". Like the todo manager, the task store is a closed status set; on success, transitioning to \"completed\" also clears the task from every other task's blockedBy via _clear_dependency().","triggerScenarios":"Calling task_update with status=\"done\", \"blocked\", \"cancelled\", \"In Progress\" (capitalized variants fail too — no lowercasing here, unlike the todo manager), or an empty-ish-but-truthy string.","commonSituations":"Models defaulting to \"done\". Code that passes a user-facing status string straight through. Note the asymmetry with s03: this file does not normalize case, so \"Completed\" fails.","solutions":["Use exactly \"pending\", \"in_progress\", or \"completed\" — lowercase, underscore","Lowercase and strip status strings at the call site if the value comes from free text","Remember blocked/cancelled states are not modeled: remove blockers via remove_blocked_by instead of inventing a status"],"exampleFix":"# before\ntasks.update(task_id=3, status=\"Done\")\n# ValueError: Invalid status: Done\n\n# after\ntasks.update(task_id=3, status=\"completed\")","handlingStrategy":"validation","validationCode":"VALID = {\"pending\", \"in_progress\", \"completed\"}\nstatus = (status or \"\").strip().lower() or None\nassert status is None or status in VALID, f\"Invalid status: {status}; use one of {sorted(VALID)}\"","typeGuard":"TASK_STATUSES = frozenset((\"pending\", \"in_progress\", \"completed\"))\n\ndef is_valid_task_status(s: object) -> bool:\n    return s is None or (isinstance(s, str) and s in TASK_STATUSES)  # note: case-sensitive","tryCatchPattern":"try:\n    TASKS.update(task_id, status)\nexcept ValueError as e:\n    if \"Invalid status\" in str(e):\n        return f\"Tool error: {e}. Allowed: pending, in_progress, completed (exact lowercase).\"\n    raise","preventionTips":["This check is case-sensitive: lower/strip status before the call","Map 'done' -> 'completed' at the call site","Model blocked/cancelled via blockedBy lists, not via status"],"tags":["validation","task-system","state-machine","python"],"backgroundTag":null,"analyzedSha":"985456f4adea6f4df8fbad4112245dbd97444eae","analyzedAt":"2026-08-14T22:02:26.028Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}