Skip to content

Commit c3ab4b4

Browse files
Fix TypeError in list_files endpoint while preserving router_error_log functionality (OpenHands#8744)
Co-authored-by: openhands <[email protected]>
1 parent 35f7efb commit c3ab4b4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

openhands/runtime/action_execution_server.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,12 +1013,12 @@ async def list_files(request: Request):
10131013

10141014
if not os.path.exists(full_path):
10151015
# if user just removed a folder, prevent server error 500 in UI
1016-
return []
1016+
return JSONResponse(content=[])
10171017

10181018
try:
10191019
# Check if the directory exists
10201020
if not os.path.exists(full_path) or not os.path.isdir(full_path):
1021-
return []
1021+
return JSONResponse(content=[])
10221022

10231023
entries = os.listdir(full_path)
10241024

@@ -1047,11 +1047,11 @@ async def list_files(request: Request):
10471047

10481048
# Combine sorted directories and files
10491049
sorted_entries = directories + files
1050-
return sorted_entries
1050+
return JSONResponse(content=sorted_entries)
10511051

10521052
except Exception as e:
10531053
logger.error(f'Error listing files: {e}')
1054-
return []
1054+
return JSONResponse(content=[])
10551055

10561056
logger.debug(f'Starting action execution API on port {args.port}')
10571057
run(app, host='0.0.0.0', port=args.port)

0 commit comments

Comments
 (0)