{"record":{"id":"335ea65e617c1735","repo":"shareAI-lab/learn-claude-code","slug":"dependency-not-found-dependency","errorCode":null,"errorMessage":"Dependency not found: {dependency}","messagePattern":"Dependency not found: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"s10_task_system/code.py","lineNumber":109,"sourceCode":"        root = self._root(create=create_root)\n        path = (root / f\"{task_id}.json\").resolve()\n        if not path.is_relative_to(root):\n            raise ValueError(f\"Invalid task ID: {task_id!r}\")\n        return path\n\n    def exists(self, task_id: str) -> bool:\n        return self._path(task_id).is_file()\n\n    def create(self, subject: str, description: str = \"\",\n               blocked_by: list[str] | None = None) -> Task:\n        subject = subject.strip()\n        if not subject:\n            raise ValueError(\"Task subject cannot be empty\")\n\n        dependencies = list(dict.fromkeys(blocked_by or []))\n        for dependency in dependencies:\n            if not self.exists(dependency):\n                raise ValueError(f\"Dependency not found: {dependency}\")\n\n        self._root(create=True)\n        for _ in range(100):\n            task = Task(\n                id=f\"task_{secrets.token_hex(4)}\",\n                subject=subject,\n                description=description,\n                status=\"pending\",\n                owner=None,\n                blockedBy=dependencies,\n            )\n            try:\n                with self._path(task.id, create_root=True).open(\n                    \"x\", encoding=\"utf-8\"\n                ) as handle:\n                    json.dump(asdict(task), handle, indent=2)\n                return task\n            except FileExistsError:","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/shareAI-lab/learn-claude-code/blob/985456f4adea6f4df8fbad4112245dbd97444eae/s10_task_system/code.py#L91-L127","documentation":"Raised by TaskStore.create() in s10_task_system/code.py:109 when a dependency listed in blocked_by does not exist as a task file in the store. Before creating a task, create() de-duplicates the blocked_by list and calls self.exists(dependency) for each entry, which resolves '{dependency}.json' under the store root. Any missing or malformed dependency ID aborts creation, preserving the invariant that blockedBy references are always live tasks.","triggerScenarios":"Calling store.create('x', blocked_by=['task_00000000']) when no such file exists; passing a dependency ID with a typo or wrong length; passing a bg_ or cron_ ID from a different subsystem; referencing a task that was deleted after you copied its ID. Note the dependency must also match the task_ ID pattern or exists() itself raises 'Invalid task ID'.","commonSituations":"Scripts that hardcode dependency IDs from a previous run in a fresh store; UIs offering a task picker fed by stale data; concurrent deletion racing with creation; multi-agent flows where one agent creates tasks referencing another agent's store.","solutions":["Verify each dependency with store.exists(dep) before create(), and drop or resolve missing ones explicitly.","Re-derive dependency IDs at runtime (e.g. look tasks up by subject with store.list()) instead of caching IDs across sessions.","If a referenced task vanished legitimately, recreate it first or create the new task without that dependency."],"exampleFix":"# before\nstore.create('ship release', blocked_by=['task_deadbeef', 'task_00000000'])\n\n# after\nblocked = [d for d in ['task_deadbeef', 'task_00000000'] if store.exists(d)]\nstore.create('ship release', blocked_by=blocked)","handlingStrategy":"validation","validationCode":"def missing_deps(store, blocked_by):\n    return [d for d in (blocked_by or []) if not store.exists(d)]","typeGuard":null,"tryCatchPattern":"try:\n    store.create(subject, blocked_by=deps)\nexcept ValueError as e:\n    if str(e).startswith('Dependency not found'):\n        deps = [d for d in deps if store.exists(d)]\n        store.create(subject, blocked_by=deps)\n    else:\n        raise","preventionTips":["Check store.exists(dep) for each dependency before create().","Resolve dependencies by listing tasks at runtime instead of caching IDs.","Handle missing dependencies explicitly: recreate the prerequisite or drop the link with a warning."],"tags":["tasks","validation","dependencies"],"backgroundTag":null,"analyzedSha":"985456f4adea6f4df8fbad4112245dbd97444eae","analyzedAt":"2026-08-14T22:02:26.028Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}