From f407382a5aab1de31a66c64c8b30f9020e82b705 Mon Sep 17 00:00:00 2001 From: Robert Brennan Date: Thu, 25 Apr 2024 15:15:06 -0400 Subject: [PATCH] handle IsADirectory errors (#1365) --- opendevin/action/fileop.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/opendevin/action/fileop.py b/opendevin/action/fileop.py index 07be0388a3..8f2cb5ab40 100644 --- a/opendevin/action/fileop.py +++ b/opendevin/action/fileop.py @@ -78,6 +78,8 @@ class FileReadAction(ExecutableAction): code_view = ''.join(read_lines) except FileNotFoundError: return AgentErrorObservation(f'File not found: {self.path}') + except IsADirectoryError: + return AgentErrorObservation(f'Path is a directory: {self.path}. You can only read files') except PermissionError: return AgentErrorObservation(f'Malformed paths not permitted: {self.path}') return FileReadObservation(path=self.path, content=code_view) @@ -133,6 +135,8 @@ class FileWriteAction(ExecutableAction): file.truncate() except FileNotFoundError: return AgentErrorObservation(f'File not found: {self.path}') + except IsADirectoryError: + return AgentErrorObservation(f'Path is a directory: {self.path}. You can only write to files') except PermissionError: return AgentErrorObservation(f'Malformed paths not permitted: {self.path}') return FileWriteObservation(content='', path=self.path)