diff --git a/aider/repo.py b/aider/repo.py index 94143b5f3..c4d0e61fe 100644 --- a/aider/repo.py +++ b/aider/repo.py @@ -293,13 +293,19 @@ class GitRepo: else: try: iterator = commit.tree.traverse() + blob = None # Initialize blob while True: try: blob = next(iterator) if blob.type == "blob": # blob is a file files.add(blob.path) except IndexError: - self.io.tool_warning(f"GitRepo: read error skipping {blob.path}") + # Handle potential index error during tree traversal + # without relying on potentially unassigned 'blob' + self.io.tool_warning( + "GitRepo: Index error encountered while reading git tree object." + " Skipping." + ) continue except StopIteration: break