{"record":{"id":"6a47aa7b56840962","repo":"abhigyanpatwari/GitNexus","slug":"short-write-while-staging-candidate-overlay","errorCode":null,"errorMessage":"short write while staging candidate overlay","messagePattern":"short write while staging candidate overlay","errorType":"exception","errorClass":"OSError","httpStatus":null,"severity":"error","filePath":"eval/workflow_bench/evolution.py","lineNumber":211,"sourceCode":"            existing = None\n        except OSError as exc:\n            raise ValueError(f\"candidate destination is unreadable: {relative}: {exc}\") from exc\n        if existing is not None and (stat.S_ISLNK(existing.st_mode) or not stat.S_ISREG(existing.st_mode)):\n            raise ValueError(f\"candidate destination must be a regular non-symlink file: {relative}\")\n\n        temporary = f\".wfbench-overlay-{secrets.token_hex(12)}\"\n        temp_descriptor = os.open(\n            temporary,\n            os.O_WRONLY | os.O_CREAT | os.O_EXCL | getattr(os, \"O_NOFOLLOW\", 0),\n            0o600,\n            dir_fd=descriptor,\n        )\n        try:\n            view = memoryview(content)\n            while view:\n                written = os.write(temp_descriptor, view)\n                if written <= 0:\n                    raise OSError(\"short write while staging candidate overlay\")\n                view = view[written:]\n            os.fchmod(temp_descriptor, 0o644)\n        except BaseException:\n            try:\n                os.unlink(temporary, dir_fd=descriptor)\n            except OSError:\n                pass\n            raise\n        finally:\n            os.close(temp_descriptor)\n        try:\n            os.replace(\n                temporary,\n                leaf,\n                src_dir_fd=descriptor,\n                dst_dir_fd=descriptor,\n            )\n        except BaseException:","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/evolution.py#L193-L229","documentation":"Thrown as an OSError inside _replace_regular_file (evolution.py:211) when os.write on the staged temp descriptor returns a value <= 0 while writing overlay content. A blocking local regular-file write should never return 0, so this signals an I/O-level failure: the filesystem is out of space, the device errored, or the descriptor became invalid. The temp file is unlinked (best-effort) and the error propagates.","triggerScenarios":"Disk full while staging the overlay temp file; an I/O error on the underlying device; the temp descriptor was closed/invalidated under the writer (signal, FS disconnect).","commonSituations":"CI runner or sandbox tmpfs out of space; a full disk on the host holding the clone; a flaky network/cloud filesystem under the worktree.","solutions":["Free disk space on the filesystem holding the clone/worktree and retry.","Move the worktree to a healthy local filesystem (not a network mount) and re-run.","Catch OSError around apply_candidate_overlay, clean up partial state, and retry once."],"exampleFix":"# before: single attempt, surfaces OSError on full disk\napply_candidate_overlay(overlay, worktree, sandbox=sandbox)\n\n# after: retry once after ensuring space\nimport shutil\nfor attempt in range(2):\n    try:\n        return apply_candidate_overlay(overlay, worktree, sandbox=sandbox)\n    except OSError as exc:\n        if 'short write' not in str(exc) or attempt:\n            raise\n        shutil.disk_usage(worktree)  # inspect; free space externally before retry","handlingStrategy":"retry","validationCode":"import shutil\nfrom pathlib import Path\n\ndef has_disk_space(path: Path, need_bytes: int) -> bool:\n    usage = shutil.disk_usage(path)\n    return usage.free >= need_bytes","typeGuard":"null","tryCatchPattern":"try:\n    apply_candidate_overlay(overlay, worktree, sandbox=sandbox)\nexcept OSError as exc:\n    if 'short write' in str(exc):\n        # free space / move worktree to local disk, then retry once\n        ...","preventionTips":["Ensure ample free disk where the clone lives before running.","Keep the worktree on a local filesystem, not a network mount.","Catch OSError and surface disk usage in the error message."],"tags":["io","disk-full","overlay","filesystem"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}