{"record":{"id":"50cc479481843d5e","repo":"abhigyanpatwari/GitNexus","slug":"task-asset-reflink-produced-an-invalid-file-entr","errorCode":null,"errorMessage":"task asset reflink produced an invalid file: {entry.path}","messagePattern":"task asset reflink produced an invalid file: (.+?)","errorType":"exception","errorClass":"SandboxError","httpStatus":null,"severity":"critical","filePath":"eval/workflow_bench/task_assets.py","lineNumber":824,"sourceCode":") -> int:\n    metadata = source.lstat()\n    if stat.S_ISLNK(metadata.st_mode) or not stat.S_ISREG(metadata.st_mode) or metadata.st_size != entry.size:\n        raise SandboxError(f\"task asset snapshot file changed: {entry.path}\")\n    temporary = destination.with_name(f\".{destination.name}.{uuid.uuid4().hex}.tmp\")\n    source_descriptor = os.open(source, os.O_RDONLY | getattr(os, \"O_CLOEXEC\", 0) | getattr(os, \"O_NOFOLLOW\", 0))\n    destination_descriptor = os.open(\n        temporary,\n        os.O_WRONLY | os.O_CREAT | os.O_EXCL | getattr(os, \"O_CLOEXEC\", 0),\n        0o600,\n    )\n    fallback_bytes = 0\n    try:\n        opened = os.fstat(source_descriptor)\n        if _mutation_identity(opened) != _mutation_identity(metadata):\n            raise SandboxError(f\"task asset snapshot file changed: {entry.path}\")\n        if _try_reflink(source_descriptor, destination_descriptor):\n            if os.fstat(destination_descriptor).st_size != entry.size:\n                raise SandboxError(f\"task asset reflink produced an invalid file: {entry.path}\")\n        else:\n            if entry.size > fallback_budget:\n                raise SandboxError(\n                    \"task asset filesystem cannot reflink the snapshot and the buffered fallback limit would be exceeded\"\n                )\n            os.ftruncate(destination_descriptor, 0)\n            os.lseek(source_descriptor, 0, os.SEEK_SET)\n            while True:\n                chunk = os.read(source_descriptor, COPY_CHUNK_BYTES)\n                if not chunk:\n                    break\n                _write_all(destination_descriptor, chunk)\n                fallback_bytes += len(chunk)\n            if fallback_bytes != entry.size:\n                raise SandboxError(f\"task asset snapshot file changed while materializing: {entry.path}\")\n        if _mutation_identity(opened) != _mutation_identity(os.fstat(source_descriptor)):\n            raise SandboxError(f\"task asset snapshot file changed while materializing: {entry.path}\")\n        os.fchmod(destination_descriptor, 0o600)","sourceCodeStart":806,"sourceCodeEnd":842,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/task_assets.py#L806-L842","documentation":"After _try_reflink reports success, _materialize_file checks that the destination's size equals entry.size. A mismatch implies the reflink produced partial or wrong content — a filesystem bug, concurrent truncation of the source between the pre-open lstat and the ioctl, or a stale manifest size.","triggerScenarios":"The source was truncated between the lstat (which sized the manifest) and the FICLONE ioctl; the filesystem reported success but the clone is partial; manifest size was recorded against a different inode.","commonSituations":"Concurrent truncation of the snapshot; btrfs/xfs returning a partial clone under space pressure; manifest captured against a since-replaced file.","solutions":["Re-prepare the snapshot so the manifest matches the on-disk file","Check filesystem health (`btrfs scrub start`, `xfs_repair -n`)","Eliminate concurrent truncaters; if unavoidable, place the cache on a non-clone filesystem so the buffered fallback runs with its own size check"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from eval.workflow_bench.proposer_sandbox import SandboxError\n\ntry:\n    snapshot.materialize(clone)\nexcept SandboxError as exc:\n    if \"reflink produced an invalid file\" in str(exc):\n        raise SystemExit(f\"reflink integrity failure; re-prepare and check fs health: {exc}\") from exc\n    raise","preventionTips":["Re-prepare the snapshot so the manifest size matches the on-disk file","Run filesystem health checks (`btrfs scrub start`, `xfs_repair -n`) on the cache volume","Eliminate concurrent truncaters of the snapshot files"],"tags":["sandbox","reflink","integrity","filesystem"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}