- Fixed session_maker mocking by directly patching the module-level variable
- Updated all failing tests to properly mock the database session
- Fixed TestUpdateConversationMetadata tests to use correct session_maker
- Fixed TestOnWrite::test_on_write_metadata_success to use correct session_maker
- Fixed TestProcessBatchOperationsBackground tests to use correct session_maker
- All 33 tests in test_event_webhook.py now pass
The main issue was that session_maker is imported directly from storage.database
at module import time, so patching 'storage.database.session_maker' wasn't
effective. Instead, we now directly patch the module-level variable in the
conversation_callback_utils module.
Co-authored-by: openhands <openhands@all-hands.dev>
- Fixed NoneType errors in conversation store, SQL app conversation info service,
conversation callback processor, and event webhook tests
- Added proper mocking of StoredConversationMetadata lazy import to use actual
OpenHands core class instead of None
- Fixed UserStore.get_user_by_id mocking in conversation store tests
- All previously failing tests now pass (23 tests verified)
Co-authored-by: openhands <openhands@all-hands.dev>
The circular import was caused by openhands.events.serialization.event
importing openhands.llm.metrics at module level, which eventually led
back to openhands.events through the config system.
Changes:
- Remove module-level import of openhands.llm.metrics classes
- Add lazy import in event_from_dict function where metrics are used
- Preserve all existing functionality while breaking the import cycle
This fixes the second circular import in the chain:
events.serialization.event → llm.metrics → config → storage → events
Co-authored-by: openhands <openhands@all-hands.dev>
The circular import was caused by openhands.events.event importing
openhands.llm.metrics at module level, which eventually led back to
openhands.events.event through the config system.
Changes:
- Move Metrics import to TYPE_CHECKING block for type annotations
- Add lazy import in llm_metrics property getter for runtime usage
- Use forward references in type annotations
- Preserve all existing functionality while breaking the import cycle
Fixes the ImportError: cannot import name 'Event' from partially
initialized module 'openhands.events.event' error.
Co-authored-by: openhands <openhands@all-hands.dev>
- Created new module openhands/events/recall_type.py with RecallType enum
- Removed RecallType from openhands/events/event.py to break circular dependency
- Updated all import statements across 13 files to use new module path
- Resolves circular import chain: sync/enrich_user_interaction_data.py ->
integrations.github.data_collector -> ... -> openhands.events.event ->
openhands.llm.metrics -> ... -> storage.conversation_callback ->
openhands.events.observation.agent -> openhands.events.event (circular)
The RecallType enum now has minimal dependencies and can be imported
without triggering the heavy dependency chain that caused the circular import.
Co-authored-by: openhands <openhands@all-hands.dev>
- Updated test database schema to include all required tables (user, org, org_member, role, stripe_customer)
- Fixed test fixtures to use unified Base and create proper table relationships
- Updated test mocking to properly handle call_sync_from_async calls in find_customer_id_by_user_id and find_or_create_customer_by_user_id methods
- All tests now pass successfully after the stripe_service.py changes
Co-authored-by: openhands <openhands@all-hands.dev>