Skip to content

Fix invalid file bug with iter_files #764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/codegen/extensions/tools/semantic_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def get_llm_edit(original_file_section: str, edit_content: str) -> str:


def _validate_edit_boundaries(original_lines: list[str], modified_lines: list[str], start_idx: int, end_idx: int) -> None:
"""Validate that the edit only modified lines within the specified boundaries.
"""Validate` that the edit only modified lines within the specified boundaries.

Args:
original_lines: Original file lines
Expand Down
13 changes: 7 additions & 6 deletions src/codegen/git/repo_operator/repo_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,13 +643,14 @@ def iter_files(

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

Expand Down
Loading