mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-08 22:38:05 -05:00
Fix: exception handling for get convo metadata (#11421)
This commit is contained in:
@@ -132,8 +132,10 @@ class JiraExistingConversationView(JiraViewInterface):
|
||||
conversation_store = await ConversationStoreImpl.get_instance(
|
||||
config, user_id
|
||||
)
|
||||
metadata = await conversation_store.get_metadata(self.conversation_id)
|
||||
if not metadata:
|
||||
|
||||
try:
|
||||
await conversation_store.get_metadata(self.conversation_id)
|
||||
except FileNotFoundError:
|
||||
raise StartingConvoException('Conversation no longer exists.')
|
||||
|
||||
provider_tokens = await self.saas_user_auth.get_provider_tokens()
|
||||
|
||||
@@ -135,8 +135,10 @@ class JiraDcExistingConversationView(JiraDcViewInterface):
|
||||
conversation_store = await ConversationStoreImpl.get_instance(
|
||||
config, user_id
|
||||
)
|
||||
metadata = await conversation_store.get_metadata(self.conversation_id)
|
||||
if not metadata:
|
||||
|
||||
try:
|
||||
await conversation_store.get_metadata(self.conversation_id)
|
||||
except FileNotFoundError:
|
||||
raise StartingConvoException('Conversation no longer exists.')
|
||||
|
||||
provider_tokens = await self.saas_user_auth.get_provider_tokens()
|
||||
|
||||
@@ -132,8 +132,10 @@ class LinearExistingConversationView(LinearViewInterface):
|
||||
conversation_store = await ConversationStoreImpl.get_instance(
|
||||
config, user_id
|
||||
)
|
||||
metadata = await conversation_store.get_metadata(self.conversation_id)
|
||||
if not metadata:
|
||||
|
||||
try:
|
||||
await conversation_store.get_metadata(self.conversation_id)
|
||||
except FileNotFoundError:
|
||||
raise StartingConvoException('Conversation no longer exists.')
|
||||
|
||||
provider_tokens = await self.saas_user_auth.get_provider_tokens()
|
||||
|
||||
@@ -263,8 +263,10 @@ class SlackUpdateExistingConversationView(SlackNewConversationView):
|
||||
# Check if conversation has been deleted
|
||||
# Update logic when soft delete is implemented
|
||||
conversation_store = await ConversationStoreImpl.get_instance(config, user_id)
|
||||
metadata = await conversation_store.get_metadata(self.conversation_id)
|
||||
if not metadata:
|
||||
|
||||
try:
|
||||
await conversation_store.get_metadata(self.conversation_id)
|
||||
except FileNotFoundError:
|
||||
raise StartingConvoException('Conversation no longer exists.')
|
||||
|
||||
provider_tokens = await saas_user_auth.get_provider_tokens()
|
||||
|
||||
@@ -137,7 +137,9 @@ class TestJiraExistingConversationView:
|
||||
):
|
||||
"""Test conversation update with no metadata"""
|
||||
mock_store = AsyncMock()
|
||||
mock_store.get_metadata.return_value = None
|
||||
mock_store.get_metadata.side_effect = FileNotFoundError(
|
||||
'No such file or directory'
|
||||
)
|
||||
mock_store_impl.return_value = mock_store
|
||||
|
||||
with pytest.raises(
|
||||
|
||||
@@ -137,7 +137,9 @@ class TestJiraDcExistingConversationView:
|
||||
):
|
||||
"""Test conversation update with no metadata"""
|
||||
mock_store = AsyncMock()
|
||||
mock_store.get_metadata.return_value = None
|
||||
mock_store.get_metadata.side_effect = FileNotFoundError(
|
||||
'No such file or directory'
|
||||
)
|
||||
mock_store_impl.return_value = mock_store
|
||||
|
||||
with pytest.raises(
|
||||
|
||||
@@ -137,7 +137,9 @@ class TestLinearExistingConversationView:
|
||||
):
|
||||
"""Test conversation update with no metadata"""
|
||||
mock_store = AsyncMock()
|
||||
mock_store.get_metadata.return_value = None
|
||||
mock_store.get_metadata.side_effect = FileNotFoundError(
|
||||
'No such file or directory'
|
||||
)
|
||||
mock_store_impl.return_value = mock_store
|
||||
|
||||
with pytest.raises(
|
||||
|
||||
@@ -38,7 +38,7 @@ async def initialize_conversation(
|
||||
selected_branch: str | None,
|
||||
conversation_trigger: ConversationTrigger = ConversationTrigger.GUI,
|
||||
git_provider: ProviderType | None = None,
|
||||
) -> ConversationMetadata | None:
|
||||
) -> ConversationMetadata:
|
||||
if conversation_id is None:
|
||||
conversation_id = uuid.uuid4().hex
|
||||
|
||||
@@ -66,13 +66,8 @@ async def initialize_conversation(
|
||||
await conversation_store.save_metadata(conversation_metadata)
|
||||
return conversation_metadata
|
||||
|
||||
try:
|
||||
conversation_metadata = await conversation_store.get_metadata(conversation_id)
|
||||
return conversation_metadata
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return None
|
||||
conversation_metadata = await conversation_store.get_metadata(conversation_id)
|
||||
return conversation_metadata
|
||||
|
||||
|
||||
async def start_conversation(
|
||||
@@ -190,9 +185,6 @@ async def create_new_conversation(
|
||||
git_provider,
|
||||
)
|
||||
|
||||
if not conversation_metadata:
|
||||
raise Exception('Failed to initialize conversation')
|
||||
|
||||
return await start_conversation(
|
||||
user_id,
|
||||
git_provider_tokens,
|
||||
|
||||
Reference in New Issue
Block a user