-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Fix issue #6037: [Bug]: [Resolver] crashes on main
#6284
base: main
Are you sure you want to change the base?
Conversation
Overview of Changes: ✅ Successfully Resolved:
🔍 No Remaining Issues: Conclusion: All issues have been successfully resolved with no outstanding concerns. |
LGTM, just order of initialization and error handling |
self.log_generator = container.logs(stream=True, follow=True) | ||
# Initialize all attributes before starting the thread on this instance | ||
self.stdout_thread = None | ||
self.log_generator = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@openhands-agent Since self.log_generator has now a type | None, so it's optional, check this file and adapt the code using log_generator so that mypy is happy. Keep it minimal, only make the absolutely necessary tweaks for that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Openhands fix success summary
The changes successfully address the feedback by properly handling the optional type of self.log_generator
. Specifically:
- The code added an explicit
self.log_generator is not None
check before attempting to access theclose
attribute in theclose()
method - This change directly addresses the mypy concern about
log_generator
being of type| None
by ensuring null safety before attribute access - The change is minimal and focused, only modifying the one location where additional type safety was needed
- The modification maintains the existing functionality while adding proper type checking
- The rest of the code already had appropriate null checks in place (in
_stream_logs()
and__del__()
)
The change will prevent potential runtime errors from trying to access attributes on None while satisfying mypy's type checking requirements. This directly resolves the feedback's request to adapt the code to handle the optional type of log_generator
in a type-safe way.
Overview of Changes:
Status: ✅ All Issues Resolved
No remaining issues identified - the changes successfully address both type safety and runtime concerns. |
This pull request fixes #6037.
The issue has been successfully resolved based on the changes made. The original error occurred because the LogStreamer class was trying to access attributes that could be None when initialization failed, specifically causing an AttributeError on 'logs' and 'stdout_thread'.
The fix addresses this by:
These changes directly prevent the original AttributeError by ensuring the attributes always exist (even if None) and adding proper error handling around their initialization and usage. The comprehensive test suite verifies the fix works by explicitly testing initialization failures, missing generators, and cleanup scenarios.
The code changes are a complete solution because they handle all paths that could have led to the original error, while maintaining proper functionality when everything works correctly. The error handling and initialization patterns implemented would prevent the reported NoneType attribute errors from occurring.
Automatic fix generated by OpenHands 🙌
To run this PR locally, use the following command: