Skip to content

Commit 23afd97

Browse files
committed
Handle deleted file diffs
1 parent 36e9cf7 commit 23afd97

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

codeclash/agents/player.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,15 @@ def _extract_modified_files_from_diff(self, diff: str) -> dict[str, str]:
188188

189189
file_contents = {}
190190
for file_path in file_paths:
191+
# Check whether the file exists in the container before attempting to cat it.
192+
# We avoid try/except by inspecting the returncode returned by the execute call.
193+
ls_result = self.environment.execute(f"ls -la '{file_path}'")
194+
if ls_result.get("returncode", 0) != 0:
195+
# File was removed or is not present in this tree. Per request, record empty string.
196+
self.logger.warning(f"File '{file_path}' not found; recording empty content.")
197+
file_contents[file_path] = ""
198+
continue
199+
191200
out = assert_zero_exit_code(
192201
self.environment.execute(f"cat '{file_path}'"),
193202
logger=self.logger,

0 commit comments

Comments
 (0)