- 
                Notifications
    
You must be signed in to change notification settings  - Fork 35
 
Fix conversation deletion error handling for permission issues #967
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?
Conversation
- Add robust error handling in delete_conversation method to handle permission errors gracefully - Implement _safe_rmtree helper function that handles read-only files and permission errors - Wrap webhook notifications and event service closing in try-catch blocks - Ensure conversation is removed from tracking even if directory cleanup fails - Add comprehensive tests for all error scenarios including permission errors, webhook failures, and directory removal failures - Prevent PermissionError exceptions from causing conversation deletion to fail completely This fixes the issue where deleting conversations would fail with unhandled PermissionError when trying to remove directories containing read-only files (e.g., Node.js cache files). Co-authored-by: openhands <[email protected]>
          
Coverage Report •
  | 
    ||||||||||||||||||||
        
          
                openhands-agent-server/openhands/agent_server/conversation_service.py
              
                Outdated
          
            Show resolved
            Hide resolved
        
      
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
| 
           @OpenHands fix the failing github action  | 
    
| 
           I'm on it! rbren can track my progress at all-hands.dev  | 
    
…irectories The delete_conversation method was only removing the conversation directory but not the workspace directory, causing test failures. Added the missing call to _safe_rmtree for the workspace working directory. This ensures both directories are cleaned up during conversation deletion, matching the expected behavior described in the comment and tests. Co-authored-by: openhands <[email protected]>
          SummaryI successfully fixed the failing GitHub action by addressing the root cause of the test failures in PR #967. Issue Identified: Two tests were failing because the  Fix Applied: Added a single missing call to  Changes Made: 
 Verification Complete: The fix ensures proper cleanup of both conversation metadata and workspace files during deletion, resolving the GitHub action failures while maintaining the existing error-handling robustness for permission issues.  | 
    
        
          
                openhands-agent-server/openhands/agent_server/conversation_service.py
              
                Outdated
          
            Show resolved
            Hide resolved
        
      | 
           Looks like there are a few issues preventing this PR from being merged! 
 If you'd like me to help, just leave a comment, like Feel free to include any additional details that might help me get this PR into a better state. You can manage your notification settings  | 
    
| 
          
 Found 4 test failures on Blacksmith runners: 
  | 
    
Problem
Users were experiencing consistent errors when trying to delete conversations with the agent server. The issue was caused by
PermissionErrorexceptions when attempting to remove directories containing read-only files (e.g., Node.js cache files):This caused the entire conversation deletion operation to fail, leaving conversations in an inconsistent state and preventing users from cleaning up their workspace.
Solution
This PR implements robust error handling for conversation deletion by:
1. New
_safe_rmtree()Helper Functiononerrorcallback2. Enhanced
delete_conversation()Methodshutil.rmtree()calls with_safe_rmtree()3. Comprehensive Error Handling
Testing
Added comprehensive test coverage including:
_safe_rmtree()function with various error scenariosAll existing tests continue to pass, ensuring backward compatibility.
Impact
Files Changed
openhands-agent-server/openhands/agent_server/conversation_service.py: Added robust error handlingtests/agent_server/test_conversation_service.py: Added comprehensive test coverageThis fix resolves the issue where deleting conversations would fail with unhandled
PermissionErrorwhen trying to remove directories containing read-only files.@rbren can click here to continue refining the PR
Agent Server images for this PR
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
golang:1.21-bookwormeclipse-temurin:17-jdknikolaik/python-nodejs:python3.12-nodejs22Pull (multi-arch manifest)
Run
All tags pushed for this build
The
77c1e80tag is a multi-arch manifest (amd64/arm64); your client pulls the right arch automatically.