You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit addresses all critical and important issues found during
the comprehensive PR review by three specialized agents.
## Critical Fixes
1. **Fixed RobotState immutability conflict** (multi_robot_coordinator.py)
- Removed numpy array immutability that conflicted with update_robot_state()
- Arrays are now mutable to allow state updates as intended
- Updated docstring to clarify arrays remain mutable
2. **Fixed CoordinatedTask field definition** (multi_robot_coordinator.py)
- Moved completion_callback field before __post_init__ method
- Was incorrectly defined after __post_init__, causing syntax error
3. **Fixed state extraction in RL environment** (rl_integration.py)
- Changed from response.get("state", {}).get("qpos") to response.get("qpos")
- Server returns qpos/qvel directly in response, not nested under "state"
- Added comment explaining the correct structure
4. **Added missing logger** (rl_integration.py)
- Added module-level logger = logging.getLogger(__name__)
- Fixes NameError when logger.error() was called at line 692
5. **Added error handling to ModelViewer.__init__** (mujoco_viewer_server.py)
- Wrapped model loading in try/except with specific error types
- Added context-rich error messages for debugging
- Handles FileNotFoundError, generic model loading errors separately
- Added error handling for MjData creation and viewer launch
6. **Replaced dangerous BaseException suppression** (mujoco_viewer_server.py)
- Replaced contextlib.suppress(BaseException) with specific exception types
- Never suppresses KeyboardInterrupt or SystemExit
- Added proper error logging for cleanup failures
- Thread timeout warning when simulation thread doesn't terminate
## Important Fixes
7. **Added thread safety to _handle_ping** (mujoco_viewer_server.py)
- Acquire viewer_lock before accessing current_viewer and current_model_id
- Prevents race conditions with concurrent model loading
8. **Improved exception handling in handle_command** (mujoco_viewer_server.py)
- Distinguish between expected errors (KeyError, ValueError, TypeError)
- Handle RuntimeError separately (expected runtime failures)
- Log unexpected exceptions with full stack traces
- Better error messages for users vs. bugs
9. **Fixed connection state in viewer_client** (viewer_client.py)
- Mark connection as failed for JSONDecodeError and UnicodeDecodeError
- Previously only OSError marked connection as failed
- Prevents continued attempts to use corrupted connections
- Updated docstring to reflect ValueError instead of JSONDecodeError
## Impact
These fixes address:
- 2 critical bugs that would cause runtime failures
- 1 syntax error in dataclass definition
- 1 missing import causing NameError
- 2 dangerous exception handling patterns
- 3 thread safety and error handling improvements
All changes preserve functionality while significantly improving:
- Error handling robustness
- Thread safety
- Error message clarity
- Connection state consistency
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
0 commit comments