Skip to content

Commit cb2329e

Browse files
authored
Fix invalid file bug with iter_files (#764)
# Motivation <!-- Why is this change necessary? --> # Content <!-- Please include a summary of the change --> # Testing <!-- How was the change tested? --> # Please check the following before marking your PR as ready for review - [ ] I have added tests for my changes - [ ] I have updated the documentation or added new documentation as needed
1 parent 0af487f commit cb2329e

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/codegen/extensions/tools/semantic_edit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def get_llm_edit(original_file_section: str, edit_content: str) -> str:
109109

110110

111111
def _validate_edit_boundaries(original_lines: list[str], modified_lines: list[str], start_idx: int, end_idx: int) -> None:
112-
"""Validate that the edit only modified lines within the specified boundaries.
112+
"""Validate` that the edit only modified lines within the specified boundaries.
113113
114114
Args:
115115
original_lines: Original file lines

src/codegen/git/repo_operator/repo_operator.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -643,13 +643,14 @@ def iter_files(
643643

644644
if extensions is None or any(filepath.endswith(e) for e in extensions):
645645
try:
646-
if not skip_content:
647-
content = self.get_file(filepath)
648-
yield rel_filepath, content
646+
if os.path.isfile(filepath):
647+
if not skip_content:
648+
content = self.get_file(filepath)
649+
yield rel_filepath, content
650+
else:
651+
yield rel_filepath, ""
649652
else:
650-
# WTF??? A no-op file read here fixes file parsing somehow?
651-
open(filepath).close()
652-
yield rel_filepath, ""
653+
logger.warning(f"Skipping {filepath} because it does not exist or is not a valid file.")
653654
except Exception as e:
654655
logger.warning(f"Error reading file {filepath}: {e}")
655656

0 commit comments

Comments
 (0)