Skip to content

Commit c6ecaff

Browse files
sjarmakclaude
andcommitted
fix: harden artifact verifier against missing patch command
- Add `patch` to Dockerfile.artifact_only apt install list - Wrap subprocess calls in try/except FileNotFoundError in artifact_verifier_lib.sh so missing executables don't crash the Python heredoc - Make apply_patches_from_review_json non-fatal in test.sh (|| echo) so scoring continues even when patches fail to apply Verified: run scored 0.55 with these fixes (was RewardFileNotFoundError). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 9f38d13 commit c6ecaff

File tree

3 files changed

+35
-25
lines changed

3 files changed

+35
-25
lines changed

benchmarks/ccb_test/aspnetcore-code-review-001/environment/Dockerfile.artifact_only

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
99
git \
1010
ca-certificates \
1111
curl \
12+
patch \
1213
python3 \
1314
ripgrep \
1415
&& rm -rf /var/lib/apt/lists/*

benchmarks/ccb_test/aspnetcore-code-review-001/tests/artifact_verifier_lib.sh

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -158,34 +158,43 @@ for entry in reported:
158158
pf_path = pf.name
159159
160160
# Try git apply
161-
result = subprocess.run(
162-
["git", "apply", "--allow-empty", pf_path],
163-
cwd=verify_repo, capture_output=True, text=True
164-
)
165-
if result.returncode == 0:
166-
applied += 1
167-
os.unlink(pf_path)
168-
continue
161+
try:
162+
result = subprocess.run(
163+
["git", "apply", "--allow-empty", pf_path],
164+
cwd=verify_repo, capture_output=True, text=True
165+
)
166+
if result.returncode == 0:
167+
applied += 1
168+
os.unlink(pf_path)
169+
continue
170+
except FileNotFoundError:
171+
pass
169172
170173
# Fallback: patch -p1 --fuzz=3
171-
result = subprocess.run(
172-
["patch", "-p1", "--fuzz=3", "-i", pf_path],
173-
cwd=verify_repo, capture_output=True, text=True
174-
)
175-
if result.returncode == 0:
176-
applied += 1
177-
os.unlink(pf_path)
178-
continue
174+
try:
175+
result = subprocess.run(
176+
["patch", "-p1", "--fuzz=3", "-i", pf_path],
177+
cwd=verify_repo, capture_output=True, text=True
178+
)
179+
if result.returncode == 0:
180+
applied += 1
181+
os.unlink(pf_path)
182+
continue
183+
except FileNotFoundError:
184+
print("[artifact_verifier] 'patch' not installed, skipping fallback", file=sys.stderr)
179185
180186
# Fallback: git apply with 3way
181-
result = subprocess.run(
182-
["git", "apply", "--allow-empty", "--3way", pf_path],
183-
cwd=verify_repo, capture_output=True, text=True
184-
)
185-
if result.returncode == 0:
186-
applied += 1
187-
os.unlink(pf_path)
188-
continue
187+
try:
188+
result = subprocess.run(
189+
["git", "apply", "--allow-empty", "--3way", pf_path],
190+
cwd=verify_repo, capture_output=True, text=True
191+
)
192+
if result.returncode == 0:
193+
applied += 1
194+
os.unlink(pf_path)
195+
continue
196+
except FileNotFoundError:
197+
pass
189198
190199
failed += 1
191200
file_name = entry.get("file", "unknown")

benchmarks/ccb_test/aspnetcore-code-review-001/tests/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ if [ "${ARTIFACT_ONLY:-false}" = "true" ]; then
3232
exit 0
3333
fi
3434
echo "Artifact mode: review.json found, applying patches to ${VERIFY_REPO}"
35-
apply_patches_from_review_json /workspace/review.json
35+
apply_patches_from_review_json /workspace/review.json || echo "[verifier] Patch application returned non-zero (non-fatal, scoring continues)"
3636
else
3737
# Legacy mode: check git changes in workspace
3838
UNSTAGED_COUNT=$(git diff --stat 2>/dev/null | wc -l)

0 commit comments

Comments
 (0)