Skip to content

πŸ™Œ OpenHands: AI-Driven Development

[Evaluation] Fix KeyError when the instance failed prematurely (#7864)

Engel Nyst5e5bf23f9c43
diff --git a/evaluation/benchmarks/swe_bench/run_infer.py b/evaluation/benchmarks/swe_bench/run_infer.py
index f28a4bcc74..d6e606558c 100644
--- a/evaluation/benchmarks/swe_bench/run_infer.py
+++ b/evaluation/benchmarks/swe_bench/run_infer.py
@@ -864,7 +864,7 @@ if __name__ == '__main__':
# Also make sure git_patch is not empty - otherwise we fall back to previous attempt (empty patch is worse than anything else)
if (
instance['instance_id'] not in added_instance_ids
- and instance['test_result']['git_patch'].strip()
+ and instance['test_result'].get('git_patch', '').strip()
):
fout.write(line)
added_instance_ids.add(instance['instance_id'])