{"record":{"id":"08e476526b52301b","repo":"shareAI-lab/learn-claude-code","slug":"invalid-status-status-08e476","errorCode":null,"errorMessage":"Invalid status: {status}","messagePattern":"Invalid status: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agents/s12_worktree_task_isolation.py","lineNumber":175,"sourceCode":"            \"blockedBy\": [],\n            \"created_at\": time.time(),\n            \"updated_at\": time.time(),\n        }\n        self._save(task)\n        self._next_id += 1\n        return json.dumps(task, indent=2)\n\n    def get(self, task_id: int) -> str:\n        return json.dumps(self._load(task_id), indent=2)\n\n    def exists(self, task_id: int) -> bool:\n        return self._path(task_id).exists()\n\n    def update(self, task_id: int, status: str = None, owner: str = 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 owner is not None:\n            task[\"owner\"] = owner\n        task[\"updated_at\"] = time.time()\n        self._save(task)\n        return json.dumps(task, indent=2)\n\n    def bind_worktree(self, task_id: int, worktree: str, owner: str = \"\") -> str:\n        task = self._load(task_id)\n        task[\"worktree\"] = worktree\n        if owner:\n            task[\"owner\"] = owner\n        if task[\"status\"] == \"pending\":\n            task[\"status\"] = \"in_progress\"\n        task[\"updated_at\"] = time.time()\n        self._save(task)\n        return json.dumps(task, indent=2)\n","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/shareAI-lab/learn-claude-code/blob/985456f4adea6f4df8fbad4112245dbd97444eae/agents/s12_worktree_task_isolation.py#L157-L193","documentation":"Raised by update() in agents/s12_worktree_task_isolation.py:175 when the status argument is truthy but outside {pending, in_progress, completed}. Same closed status set as s07 and also case-sensitive (no lowercasing), so \"Completed\" or \"done\" fail. On valid transitions the method also stamps updated_at.","triggerScenarios":"task_update with status \"done\", \"cancelled\", \"blocked\", \"In_Progress\", or any free-text value. Passing status=\"\" is falsy and silently skips the check (no error, no change) — a quieter trap worth knowing.","commonSituations":"Models abbreviating to \"done\". Passing user-facing strings unnormalized. Expecting cancelled/blocked states that the worktree task schema does not have.","solutions":["Use exactly \"pending\", \"in_progress\", \"completed\"","Normalize at the call site: status.strip().lower() and map \"done\"->\"completed\"","Do not rely on status=\"\" to mean pending — it means 'leave unchanged'"],"exampleFix":"# before\ntasks.update(task_id=4, status=\"In_Progress\")\n# ValueError: Invalid status: In_Progress\n\n# after\nstatus = \"in_progress\"\ntasks.update(task_id=4, status=status)","handlingStrategy":"validation","validationCode":"VALID = {\"pending\", \"in_progress\", \"completed\"}\nstatus = status.strip().lower() if isinstance(status, str) else None\nstatus = {\"done\": \"completed\"}.get(status, status)\nassert status is None or status in VALID, f\"Invalid status: {status}; allowed {sorted(VALID)}\"","typeGuard":"WORKTREE_STATUSES = frozenset((\"pending\", \"in_progress\", \"completed\"))\n\ndef is_valid_worktree_status(s: object) -> bool:\n    return s is None or (isinstance(s, str) and s in WORKTREE_STATUSES)  # case-sensitive; '' means unchanged","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":["Lowercase and strip status before the call; map 'done' to 'completed'","Remember empty/None status means 'leave unchanged', not 'pending'","No cancelled/blocked status exists — use owner/worktree fields for extra state"],"tags":["validation","task-system","worktree","state-machine","python"],"backgroundTag":null,"analyzedSha":"985456f4adea6f4df8fbad4112245dbd97444eae","analyzedAt":"2026-08-14T22:02:26.028Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}