{"record":{"id":"f4d9f7c3d2bc66d0","repo":"HKUDS/Vibe-Trading","slug":"task-task-id-depends-on-unknown-task-dep","errorCode":null,"errorMessage":"Task '{task.id}' depends on unknown task '{dep}'","messagePattern":"Task '(.+?)' depends on unknown task '(.+?)'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/swarm/task_store.py","lineNumber":165,"sourceCode":"    return newly_unblocked\n\n\ndef validate_dag(tasks: list[SwarmTask]) -> None:\n    \"\"\"DFS cycle detection to ensure the task DAG is acyclic.\n\n    Args:\n        tasks: List of SwarmTask.\n\n    Raises:\n        ValueError: If a cycle is detected; message includes the cycle path.\n    \"\"\"\n    graph: dict[str, list[str]] = {t.id: list(t.depends_on) for t in tasks}\n    all_ids = {t.id for t in tasks}\n\n    for task in tasks:\n        for dep in task.depends_on:\n            if dep not in all_ids:\n                raise ValueError(\n                    f\"Task '{task.id}' depends on unknown task '{dep}'\"\n                )\n\n    WHITE, GRAY, BLACK = 0, 1, 2\n    color: dict[str, int] = {tid: WHITE for tid in all_ids}\n    path: list[str] = []\n\n    def dfs(node: str) -> None:\n        \"\"\"DFS traversal to detect back edges.\n\n        Args:\n            node: Current node ID.\n\n        Raises:\n            ValueError: If a cycle is detected.\n        \"\"\"\n        color[node] = GRAY\n        path.append(node)","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/swarm/task_store.py#L147-L183","documentation":"validate_dag checks every task's depends_on entries against the set of known task ids; an unknown dependency raises ValueError. This catches typos and forward references to tasks that were never defined in the preset/run.","triggerScenarios":"A preset task with depends_on: ['fetch-mkt-data'] when the producing task is actually named 'fetch_market_data'; dependency on a task that a conditional branch excluded.","commonSituations":"Renaming tasks in a preset without updating dependents; conditionally skipping a producer task while its consumers still run.","solutions":["Fix the dependency id to match an existing task id exactly","If the producer was removed/renamed, update or remove the depends_on entry accordingly","Run validate_dag (or inspect_preset) immediately after editing preset YAML"],"exampleFix":"# before\ntasks=[SwarmTask(id='analyze', depends_on=['fetch-mkt-data']), ...]\n# after\ntasks=[SwarmTask(id='analyze', depends_on=['fetch_market_data']), SwarmTask(id='fetch_market_data', depends_on=[])]","handlingStrategy":"validation","validationCode":"all_ids = {t.id for t in tasks}\nbad = [(t.id, d) for t in tasks for d in t.depends_on if d not in all_ids]\nif bad: raise ValueError(f'unknown deps: {bad}')\nvalidate_dag(tasks)","typeGuard":"def deps_resolve(tasks) -> bool:\n    ids = {t.id for t in tasks}\n    return all(d in ids for t in tasks for d in t.depends_on)","tryCatchPattern":"try:\n    validate_dag(tasks)\nexcept ValueError as e:\n    if 'unknown task' in str(e): fix or drop the depends_on entry, re-validate\n    else: raise","preventionTips":["Run validate_dag (or inspect_preset) right after editing presets","Rename tasks with a project-wide search including depends_on","Lint presets in CI"],"tags":["python","dag","dependency-validation"],"backgroundTag":"unknown-dependency-reference","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}