π OpenHands: AI-Driven Development
[CLI] Fix errno 21 warning when reading directory (#9990)
Ryan H. Tranb67db15f8afb
diff --git a/openhands/runtime/impl/cli/cli_runtime.py b/openhands/runtime/impl/cli/cli_runtime.pyindex 6e1e635a69..aab98a3db8 100644--- a/openhands/runtime/impl/cli/cli_runtime.py+++ b/openhands/runtime/impl/cli/cli_runtime.py@@ -530,10 +530,6 @@ class CLIRuntime(Runtime):file_path = self._sanitize_filename(action.path)- # Cannot read binary files- if os.path.exists(file_path) and is_binary(file_path):- return ErrorObservation('ERROR_BINARY_FILE')-# Use OHEditor for OH_ACI implementation sourceif action.impl_source == FileReadSource.OH_ACI:result_str, _ = self._execute_file_editor(@@ -557,6 +553,10 @@ class CLIRuntime(Runtime):if os.path.isdir(file_path):return ErrorObservation(f'Cannot read directory: {action.path}')+ # Cannot read binary files+ if is_binary(file_path):+ return ErrorObservation('ERROR_BINARY_FILE')+# Read the filewith open(file_path, 'r', encoding='utf-8', errors='replace') as f:content = f.read()