{"record":{"id":"d23be020379401fc","repo":"abhigyanpatwari/GitNexus","slug":"task-asset-snapshot-does-not-match-this-dependency","errorCode":null,"errorMessage":"task asset snapshot does not match this dependency declaration","messagePattern":"task asset snapshot does not match this dependency declaration","errorType":"exception","errorClass":"SandboxError","httpStatus":null,"severity":"error","filePath":"eval/workflow_bench/task_assets.py","lineNumber":1053,"sourceCode":"        \"sandbox_dependencies\": task.get(\"sandbox_dependencies\", []),\n    }\n    with tempfile.TemporaryDirectory(prefix=\"wfbench-dependency-binding-\") as temporary:\n        with TaskAssetCache(Path(temporary) / \"cache\") as cache:\n            snapshot = cache.prepare(dependency_task, repo=repo, resolved_sha=resolved_sha)\n            return snapshot.dependency_binding\n\n\ndef _dependency_mounts(\n    task: Mapping[str, Any],\n    *,\n    clone: Path,\n    snapshot: TaskAssetSnapshot,\n) -> list[ReadOnlyMount]:\n    declarations = tuple(\n        (declaration.source, declaration.target) for declaration in _sandbox_dependency_declarations(task)\n    )\n    if snapshot.dependency_declarations != declarations:\n        raise SandboxError(\"task asset snapshot does not match this dependency declaration\")\n    return snapshot.dependency_mounts(clone)\n\n\ndef stage_task_assets(\n    task: Mapping[str, Any],\n    *,\n    repo: Path,\n    clone: Path,\n    snapshot: TaskAssetSnapshot | None = None,\n) -> list[ReadOnlyMount]:\n    \"\"\"Materialize copied assets and validate read-only dependency mounts.\n\n    ``snapshot`` is supplied by the benchmark runner so every arm reuses one\n    capture.  The optional path preserves the historic standalone helper API\n    for containment tests and external callers.\n    \"\"\"\n\n    repo_identity = _real_directory(repo, label=\"task asset repository\")","sourceCodeStart":1035,"sourceCodeEnd":1071,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/task_assets.py#L1035-L1071","documentation":"Raised by _dependency_mounts when the snapshot's recorded dependency_declarations (tuples of (source,target)) do not equal the (source,target) pairs parsed from the current task's sandbox_dependencies. The snapshot must have been built from exactly the same dependency declarations as the task being staged, otherwise the dependency mounts would not correspond to real captured bytes.","triggerScenarios":"stage_task_assets is called with a snapshot built from a task whose sandbox_dependencies list differs (added/removed/reordered/edited source or target) from the task passed to stage_task_assets. The snapshot check at line 1074 passed (same repo_identity and sandbox_copy declarations) but the dependency list diverged.","commonSituations":"Two tasks share the same sandbox_copy but different sandbox_dependencies, and the runner hands the wrong snapshot to one; editing a dependency target between snapshot prepare and stage; reordering sandbox_dependencies entries (the comparison is positional tuple equality).","solutions":["Prepare the snapshot from the exact same task dict you later stage: same sandbox_dependencies list, same order, same source/target strings.","If you reuse snapshots across tasks, key them by the full task declaration (including sandbox_dependencies), not just repo_identity + sandbox_copy.","Do not reorder or edit sandbox_dependencies entries between cache.prepare and stage_task_assets."],"exampleFix":"# before: snapshot built from task A, staged against task B (different deps)\nsnapshot = cache.prepare(task_a, repo=repo, resolved_sha=sha)\nstage_task_assets(task_b, repo=repo, clone=clone, snapshot=snapshot)  # -> mismatch\n\n# after: build and stage from the same task object\ntask = load_task(...)\nsnapshot = cache.prepare(task, repo=repo, resolved_sha=sha)\nstage_task_assets(task, repo=repo, clone=clone, snapshot=snapshot)","handlingStrategy":"validation","validationCode":"from .task_assets import _sandbox_dependency_declarations\n\ndef assert_snapshot_matches_deps(task, snapshot) -> None:\n    decls = tuple((d.source, d.target) for d in _sandbox_dependency_declarations(task))\n    if snapshot.dependency_declarations != decls:\n        raise ValueError(\n            f'snapshot deps {snapshot.dependency_declarations!r} != task deps {decls!r}; '\n            'prepare the snapshot from this exact task.'\n        )\n\n# Call before stage_task_assets; rebuild the snapshot if it does not match.","typeGuard":"def snapshot_matches_deps(task, snapshot) -> bool:\n    decls = tuple((d.source, d.target) for d in _sandbox_dependency_declarations(task))\n    return snapshot.dependency_declarations == decls","tryCatchPattern":"from .proposer_sandbox import SandboxError\n\ntry:\n    stage_task_assets(task, repo=repo, clone=clone, snapshot=snapshot)\nexcept SandboxError as exc:\n    if 'does not match this dependency declaration' in str(exc):\n        # Rebuild snapshot from the current task and retry exactly once.\n        with TaskAssetCache(cache_dir) as cache:\n            snapshot = cache.prepare(task, repo=repo, resolved_sha=sha)\n        stage_task_assets(task, repo=repo, clone=clone, snapshot=snapshot)\n    else:\n        raise","preventionTips":["Build the snapshot from the exact task dict you will stage — same sandbox_dependencies, same order.","Key any snapshot cache by the full task declaration, including sandbox_dependencies.","Never reorder or edit sandbox_dependencies entries between prepare and stage."],"tags":["dependencies","snapshot","validation","sandbox"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}