{"record":{"id":"0fda206dfe0e3073","repo":"shareAI-lab/learn-claude-code","slug":"dependency-not-found-dependency-0fda20","errorCode":null,"errorMessage":"Dependency not found: {dependency}","messagePattern":"Dependency not found: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"s15_integrated_harness/code.py","lineNumber":217,"sourceCode":"    if not isinstance(task_id, str) or not TASK_ID_PATTERN.fullmatch(task_id):\n        raise ValueError(f\"Invalid task ID: {task_id!r}\")\n    path = (TASKS_DIR / f\"{task_id}.json\").resolve()\n    if (not TASKS_ROOT.is_relative_to(WORKDIR.resolve())\n            or not path.is_relative_to(TASKS_ROOT)):\n        raise ValueError(f\"Invalid task ID: {task_id!r}\")\n    return path\n\n\ndef create_task(subject: str, description: str = \"\",\n                blockedBy: list[str] | None = None) -> Task:\n    subject = subject.strip()\n    if not subject:\n        raise ValueError(\"Task subject cannot be empty\")\n    dependencies = list(dict.fromkeys(blockedBy or []))\n    with task_store_lock():\n        for dependency in dependencies:\n            if not _task_path(dependency).is_file():\n                raise ValueError(f\"Dependency not found: {dependency}\")\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 _task_path(task.id).open(\"x\", encoding=\"utf-8\") as handle:\n                    json.dump(asdict(task), handle, indent=2)\n                return task\n            except FileExistsError:\n                continue\n    raise RuntimeError(\"Could not allocate a unique task ID\")\n\n","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/shareAI-lab/learn-claude-code/blob/985456f4adea6f4df8fbad4112245dbd97444eae/s15_integrated_harness/code.py#L199-L235","documentation":"create_task() validates every entry in blockedBy before writing the new task: each dependency must already exist as a task file in the tasks store. Referencing an unknown dependency would create a permanently unsatisfiable blocker, so it fails fast under the store lock.","triggerScenarios":"Calling create_task(blockedBy=[\"task_deadbeef\"]) where that file does not exist in TASKS_DIR; using an ID from a different workspace; a typo or truncated ID; a dependency that was deleted between listing and creating (TOCTOU window closed by the lock check).","commonSituations":"Agent invents a dependency ID instead of reading list_tasks(); tasks directory reset/cleaned while a session holds old IDs; copy-pasting IDs across environments.","solutions":["Call list_tasks() first and use exact existing IDs for blockedBy.","Create the dependency task before the task that blocks on it.","Double-check the ID against task_<8 hex chars> format — a typo is the most common cause."],"exampleFix":"// before\ncreate_task(\"Ship release\", blockedBy=[\"task_00000000\"])\n\n// after\nexisting = {t.id for t in list_tasks()}\ndeps = [d for d in [\"task_0f1e2d3c\"] if d in existing]\ncreate_task(\"Ship release\", blockedBy=deps)","handlingStrategy":"validation","validationCode":"existing = {t.id for t in list_tasks()}\nmissing = [d for d in blockedBy if d not in existing]\nif missing:\n    raise ValueError(f\"Unknown dependencies: {missing}\")\ntask = create_task(subject, description, blockedBy=blockedBy)","typeGuard":"def deps_exist(deps, existing_ids) -> bool:\n    return all(d in existing_ids for d in deps)","tryCatchPattern":"try:\n    create_task(subject, description, blockedBy=deps)\nexcept ValueError as e:\n    if \"Dependency not found\" in str(e):\n        deps = [d for d in deps if d in {t.id for t in list_tasks()}]\n        # re-ask or create missing deps, then retry once","preventionTips":["Always resolve dependency IDs from list_tasks() in the same session.","Create dependencies before dependents.","Re-list tasks after any reset/cleanup before reusing old IDs."],"tags":["task","dependencies","validation"],"backgroundTag":null,"analyzedSha":"985456f4adea6f4df8fbad4112245dbd97444eae","analyzedAt":"2026-08-14T22:02:26.028Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}