{"record":{"id":"79db2683ec5831b0","repo":"HKUDS/Vibe-Trading","slug":"task-not-found-path-name","errorCode":null,"errorMessage":"Task not found: {path.name}","messagePattern":"Task not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"agent/src/swarm/task_store.py","lineNumber":73,"sourceCode":"        with self._lock:\n            tmp_path.write_text(task.model_dump_json(indent=2), encoding=\"utf-8\")\n            tmp_path.replace(path)\n\n    def load_task(self, task_id: str) -> SwarmTask:\n        \"\"\"Load a task by ID.\n\n        Args:\n            task_id: Task ID.\n\n        Returns:\n            SwarmTask instance.\n\n        Raises:\n            FileNotFoundError: If the task file does not exist.\n        \"\"\"\n        path = self._task_path(task_id)\n        if not path.exists():\n            raise FileNotFoundError(f\"Task not found: {path.name}\")\n        return SwarmTask.model_validate_json(path.read_text(encoding=\"utf-8\"))\n\n    def load_all(self) -> list[SwarmTask]:\n        \"\"\"Load all tasks for the current run.\n\n        Returns:\n            List of SwarmTask sorted by ID.\n        \"\"\"\n        tasks: list[SwarmTask] = []\n        for path in sorted(self._tasks_dir.glob(\"task-*.json\")):\n            tasks.append(\n                SwarmTask.model_validate_json(path.read_text(encoding=\"utf-8\"))\n            )\n        return tasks\n\n    def update_status(\n        self, task_id: str, status: TaskStatus, **kwargs: str | int | list[str] | None\n    ) -> SwarmTask:","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/swarm/task_store.py#L55-L91","documentation":"TaskStore.load_task reads <run_dir>/tasks/<task_id>.json and raises FileNotFoundError when the file is missing — the task id was never written (create/save not called) or belongs to a different run.","triggerScenarios":"load_task('t9') when only t1..t5 were persisted; calling load_task against a TaskStore bound to a different run directory; a worker reporting a task id that was never created.","commonSituations":"Retry/resume flows after partial task creation; typos in task ids; store instances pointing at the wrong base_dir.","solutions":["Create/save tasks via the store before loading them","List existing ids with load_all() (or inspect the tasks dir) to confirm the id","Verify the TaskStore was constructed for the correct run"],"exampleFix":"# before\ntask = store.load_task('t42')\n# after\nids = {t.id for t in store.load_all()}\ntask = store.load_task('t42') if 't42' in ids else None","handlingStrategy":"validation","validationCode":"known = {t.id for t in store.load_all()}\nif task_id not in known:\n    raise KeyError(f'task {task_id} not in run')\ntask = store.load_task(task_id)","typeGuard":null,"tryCatchPattern":"try:\n    task = store.load_task(task_id)\nexcept FileNotFoundError as e:\n    if 'Task not found' in str(e): skip/recreate the task\n    else: raise","preventionTips":["Persist tasks before workers can reference them","Validate task ids against load_all() on resume","Bind TaskStore to the correct run directory"],"tags":["python","file-not-found","swarm","tasks"],"backgroundTag":"file-not-found","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}