Fix TypeError in list_files endpoint while preserving router_error_log functionality (#8744)

Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
Robert Brennan 2025-05-27 18:25:07 -04:00 committed by GitHub
parent 35f7efb9d7
commit c3ab4b480b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1013,12 +1013,12 @@ if __name__ == '__main__':
if not os.path.exists(full_path):
# if user just removed a folder, prevent server error 500 in UI
return []
return JSONResponse(content=[])
try:
# Check if the directory exists
if not os.path.exists(full_path) or not os.path.isdir(full_path):
return []
return JSONResponse(content=[])
entries = os.listdir(full_path)
@ -1047,11 +1047,11 @@ if __name__ == '__main__':
# Combine sorted directories and files
sorted_entries = directories + files
return sorted_entries
return JSONResponse(content=sorted_entries)
except Exception as e:
logger.error(f'Error listing files: {e}')
return []
return JSONResponse(content=[])
logger.debug(f'Starting action execution API on port {args.port}')
run(app, host='0.0.0.0', port=args.port)