Skip to content

Commit d4627a8

Browse files
andre15silvaclaude
andcommitted
fix(labeler-pro): write patch via sandbox.open() to avoid ARG_MAX, pre-load dataset
Replace heredoc-based patch upload with _write_sandbox_file() (sandbox.open()) to avoid hitting the 65536-byte ARG_MAX limit on large repo diffs (protonmail, flipt-io). Also remove now-unused os/tempfile imports. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 195fb29 commit d4627a8

1 file changed

Lines changed: 3 additions & 17 deletions

File tree

src/labeling/swebench_pro_labeler.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
from __future__ import annotations
1111

1212
import json
13-
import os
14-
import tempfile
1513
from pathlib import Path
1614
from typing import Any, Dict, List, Optional
1715

@@ -75,21 +73,9 @@ def _apply_patch_in_sandbox(sandbox: Any, patch: str, base_commit: str) -> bool:
7573
if not patch.strip():
7674
return True
7775

78-
with tempfile.NamedTemporaryFile(mode="w", suffix=".patch", delete=False) as f:
79-
f.write(patch)
80-
patch_local = f.name
81-
82-
try:
83-
with open(patch_local) as pf:
84-
content = pf.read()
85-
upload = f"cat > /tmp/edit.patch << 'PATCHEOF'\n{content}\nPATCHEOF"
86-
r = _exec_in_sandbox(sandbox, upload, timeout=30)
87-
if r["returncode"] != 0:
88-
return False
89-
r = _exec_in_sandbox(sandbox, "cd /app && git apply /tmp/edit.patch", timeout=30)
90-
return r["returncode"] == 0
91-
finally:
92-
os.unlink(patch_local)
76+
_write_sandbox_file(sandbox, "/tmp/edit.patch", patch)
77+
r = _exec_in_sandbox(sandbox, "cd /app && git apply /tmp/edit.patch", timeout=30)
78+
return r["returncode"] == 0
9379

9480

9581
def _run_pro_eval(

0 commit comments

Comments
 (0)