Fix: exception handling for get convo metadata (#11421)

This commit is contained in:
Rohit Malhotra
2025-10-17 14:12:18 -04:00
committed by GitHub
parent 6f2f85073d
commit 640f50d525
8 changed files with 28 additions and 22 deletions

View File

@@ -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()

View File

@@ -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()

View File

@@ -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()

View File

@@ -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()

View File

@@ -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(

View File

@@ -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(

View File

@@ -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(

View File

@@ -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,