Skip to content

Commit 103865d

Browse files
committed
refactor: rename get_async_azure_credential to build_async_azure_credential
Addresses Copilot review feedback on PR #915 (merged into dev). The two helpers get_azure_credential_async (async fn) and get_async_azure_credential (sync fn) differ only by word order, which is easy to confuse at call sites. Renaming the sync builder to build_async_azure_credential makes the sync-vs-async distinction explicit: build_ implies sync construction, async describes the returned credential type. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent a41ccc4 commit 103865d

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/api/helpers/azure_credential_utils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@ def get_azure_credential(client_id=None):
4141
return ManagedIdentityCredential(client_id=client_id)
4242

4343

44-
def get_async_azure_credential(client_id=None):
44+
def build_async_azure_credential(client_id=None):
4545
"""
46-
Synchronously returns an async Azure credential suitable for async SDK clients
47-
(e.g., azure.cosmos.aio.CosmosClient). Mirrors get_azure_credential_async but
48-
is callable from sync code paths.
46+
Synchronously builds an async Azure credential suitable for async SDK clients
47+
(e.g., azure.cosmos.aio.CosmosClient). Use this from sync constructors that
48+
need to hand an async-capable credential to an async client; use
49+
get_azure_credential_async() instead from `async with` blocks.
4950
"""
5051
if os.getenv("APP_ENV", "prod").lower() == 'dev':
5152
return AioAzureCliCredential()

src/api/services/history_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from azure.ai.projects.aio import AIProjectClient
66
from common.config.config import Config
77
from common.database.cosmosdb_service import CosmosConversationClient
8-
from helpers.azure_credential_utils import get_azure_credential_async, get_async_azure_credential
8+
from helpers.azure_credential_utils import get_azure_credential_async, build_async_azure_credential
99

1010
from agent_framework.azure import AzureAIProjectAgentProvider
1111

@@ -46,7 +46,7 @@ def init_cosmosdb_client(self):
4646

4747
return CosmosConversationClient(
4848
cosmosdb_endpoint=cosmos_endpoint,
49-
credential=get_async_azure_credential(client_id=self.azure_client_id),
49+
credential=build_async_azure_credential(client_id=self.azure_client_id),
5050
database_name=self.azure_cosmosdb_database,
5151
container_name=self.azure_cosmosdb_conversations_container,
5252
enable_message_feedback=self.azure_cosmosdb_enable_feedback,

0 commit comments

Comments
 (0)