-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Feat/add openarm #2449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Feat/add openarm #2449
Conversation
* adding first attempt at gcompensation to open arms * add teleop with gravity compensation script
| ser.close() | ||
| return {"status": "success", "message": f"Port {port} is accessible"} | ||
| except PermissionError as e: | ||
| return {"status": "error", "message": f"Permission denied: {e}"} |
Check warning
Code scanning / CodeQL
Information exposure through an exception Medium
Stack trace information
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
To address the information exposure, the code should avoid returning raw exception messages to users, especially those containing details from e or stack traces. Instead, a generic error message should be sent to the client, while detailed error logging (optionally including the exception message/stack trace) should occur server-side for diagnostics. The fix should target the exception handling blocks within the test_usb_port endpoint (lines 220-224), replacing exception details in API responses with generic messages, and logging the exceptions using a standard logging library (such as Python's built-in logging module). This change will require importing the logging library at the top of the file and initializing a logger, then updating exception handlers to use the logger instead of exposing details through API responses.
-
Copy modified line R18 -
Copy modified lines R221-R222 -
Copy modified lines R224-R225 -
Copy modified lines R227-R228
| @@ -15,6 +15,7 @@ | ||
| from pathlib import Path | ||
| from typing import Optional, Any | ||
| import threading | ||
| import logging | ||
|
|
||
| import cv2 | ||
| import numpy as np | ||
| @@ -217,11 +218,14 @@ | ||
| ser.close() | ||
| return {"status": "success", "message": f"Port {port} is accessible"} | ||
| except PermissionError as e: | ||
| return {"status": "error", "message": f"Permission denied: {e}"} | ||
| logger.warning(f"[USB Test] PermissionError for port {port}: {e}") | ||
| return {"status": "error", "message": "Permission denied to access the port."} | ||
| except serial.SerialException as e: | ||
| return {"status": "error", "message": f"Serial error: {e}"} | ||
| logger.warning(f"[USB Test] SerialException for port {port}: {e}") | ||
| return {"status": "error", "message": "Serial communication error."} | ||
| except Exception as e: | ||
| return {"status": "error", "message": f"Error: {e}"} | ||
| logger.error(f"[USB Test] Unexpected error for port {port}: {e}", exc_info=True) | ||
| return {"status": "error", "message": "An unexpected error occurred while testing the port."} | ||
|
|
||
|
|
||
| @app.get("/api/can/interfaces") |
| except PermissionError as e: | ||
| return {"status": "error", "message": f"Permission denied: {e}"} | ||
| except serial.SerialException as e: | ||
| return {"status": "error", "message": f"Serial error: {e}"} |
Check warning
Code scanning / CodeQL
Information exposure through an exception Medium
Stack trace information
| except serial.SerialException as e: | ||
| return {"status": "error", "message": f"Serial error: {e}"} | ||
| except Exception as e: | ||
| return {"status": "error", "message": f"Error: {e}"} |
Check warning
Code scanning / CodeQL
Information exposure through an exception Medium
Stack trace information
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
To fix the issue, we should ensure that the /api/usb/test/{port:path} endpoint does not reveal internal exception information to the client. Instead, we should:
- Log the full exception (optionally with stack trace) server-side.
- Return only a generic error message in the API response if an unexpected exception occurs.
Specific changes:
- Modify line 224 to log the exception details (using Python's standard
loggingmodule, which will require its import near the top) and return a generic error message (e.g.,"An internal error has occurred.") to the client. - Add the import for the
loggingmodule if it doesn't already exist in the snippet. - Optionally, configure logging at the start of the file so logs are properly captured.
All changes are to be made within examples/openarms_web_interface/web_record_server.py, specifically in the definition of the /api/usb/test/{port:path} endpoint and at the top of the file for imports/configuration.
-
Copy modified line R21 -
Copy modified lines R225-R226
| @@ -18,6 +18,7 @@ | ||
|
|
||
| import cv2 | ||
| import numpy as np | ||
| import logging | ||
| from fastapi import FastAPI, HTTPException | ||
| from fastapi.middleware.cors import CORSMiddleware | ||
| from fastapi.responses import StreamingResponse | ||
| @@ -221,9 +222,9 @@ | ||
| except serial.SerialException as e: | ||
| return {"status": "error", "message": f"Serial error: {e}"} | ||
| except Exception as e: | ||
| return {"status": "error", "message": f"Error: {e}"} | ||
| logging.error(f"Unexpected error in test_usb_port({port}):", exc_info=True) | ||
| return {"status": "error", "message": "An internal error has occurred."} | ||
|
|
||
|
|
||
| @app.get("/api/can/interfaces") | ||
| async def get_can_interfaces(): | ||
| """Get available CAN interfaces.""" |
Signed-off-by: Caroline Pascal <[email protected]>
Signed-off-by: Caroline Pascal <[email protected]>
Signed-off-by: Caroline Pascal <[email protected]>
* add visualize_dataset call from `lerobot_dataset_viz` in web record server * add delete button * fixes * remove viz * unused import
What this does
This PR adds the Damiao motorbus and open arms bimanual robot (follower) and leader