Răsfoiți Sursa

fix: Handle invalid exit code conversion (#1915)

மனோஜ்குமார் பழனிச்சாமி 1 an în urmă
părinte
comite
4612e107c9

+ 2 - 0
opendevin/controller/agent_controller.py

@@ -1,4 +1,5 @@
 import asyncio
+import traceback
 from typing import Optional, Type
 
 from opendevin.controller.agent import Agent
@@ -109,6 +110,7 @@ class AgentController:
                 logger.info('AgentController task was cancelled')
                 break
             except Exception as e:
+                traceback.print_exc()
                 logger.error(f'Error while running the agent: {e}')
                 await self.report_error(
                     'There was an unexpected error while running the agent', exception=e

+ 9 - 3
opendevin/runtime/docker/ssh_box.py

@@ -474,9 +474,15 @@ class DockerSSHBox(Sandbox):
                 return self._send_interrupt(
                     cmd, command_output, ignore_last_output=True
                 )
-        exit_code = int(
-            exit_code_str.replace('echo $?', '').replace('\r\n', '').strip()
-        )
+        cleaned_exit_code_str = exit_code_str.replace('echo $?', '').strip()
+
+        try:
+            exit_code = int(cleaned_exit_code_str)
+        except ValueError:
+            logger.error(f'Invalid exit code: {cleaned_exit_code_str}')
+            # Handle the invalid exit code appropriately (e.g., raise an exception or set a default value)
+            exit_code = -1  # or some other appropriate default value
+
         return exit_code, command_output
 
     def copy_to(self, host_src: str, sandbox_dest: str, recursive: bool = False):