chore: Dev to Main - #686
Conversation
Coverage Report •
|
||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Pull request overview
This pull request updates Azure credential selection for the ContentProcessor utilities, aiming to differentiate production vs. development behavior using APP_ENV, and aligns async token-provider creation and tests with the updated (non-async) credential factory.
Changes:
- Updated async bearer token provider helpers to call
get_async_azure_credential()synchronously (noawait). - Modified
get_async_azure_credential()to prefer managed identity whenAPP_ENV=prod, and fall back toAsyncDefaultAzureCredentialotherwise, with updated logging. - Updated unit tests to set
APP_ENV=devand to patch the (now non-async) credential factory appropriately.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/ContentProcessor/src/libs/utils/azure_credential_utils.py | Adjusts async credential selection logic based on APP_ENV and updates fallback/logging behavior. |
| src/ContentProcessor/src/libs/utils/credential_util.py | Removes await when retrieving the async credential factory for token-provider creation. |
| src/tests/ContentProcessor/utils/test_azure_credential_utils.py | Updates environment setup to set APP_ENV=dev to match new fallback behavior. |
| src/tests/ContentProcessor/utils/test_azure_credential_utils_extended.py | Updates environment setup and mocking to match the non-async credential factory behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
fix: Identity provider authentication issue resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Suppressed comments (2)
src/tests/ContentProcessor/utils/test_azure_credential_utils_extended.py:112
- This test tries to clear all Azure-environment indicator variables to force the local-dev credential path, but it misses
CONTAINER_REGISTRY_LOGIN(which is part ofazure_env_indicatorsin the production code). If that env var is set in CI, the test can become flaky by taking the managed-identity branch instead.
for key in ["WEBSITE_SITE_NAME", "AZURE_CLIENT_ID", "MSI_ENDPOINT",
"IDENTITY_ENDPOINT", "KUBERNETES_SERVICE_HOST"]:
monkeypatch.delenv(key, raising=False)
monkeypatch.setenv("APP_ENV", "dev")
src/ContentProcessor/src/libs/utils/azure_credential_utils.py:198
APP_ENVis checked only after returning the first CLI credential (lines 188–192), soAPP_ENV=prodcan still returnAsyncAzureCliCredential/AsyncAzureDeveloperCliCredential. Also, the currentif app_env == "prod"means values likestaging/testfall back toAsyncDefaultAzureCredential, which contradicts the stated intent of using managed identity outside development (and differs from the API-side logic that treats onlydevspecially).
app_env = os.getenv("APP_ENV", "prod").lower()
if app_env == "prod":
client_id = os.getenv("AZURE_CLIENT_ID")
if client_id:
logging.info(
Purpose
APP_ENVenvironment variable. The main change is to ensure that in production, the code prefers user-assigned or system-assigned managed identities, and only falls back toAsyncDefaultAzureCredentialin development. Additionally, the way credentials are retrieved in async functions has been adjusted, and tests have been updated to reflect the new logic.Azure credential selection logic:
src/ContentProcessor/src/libs/utils/azure_credential_utils.py: Changedget_async_azure_credential()to checkAPP_ENV; in production, it now uses user-assigned or system-assigned managed identity, and only falls back toAsyncDefaultAzureCredentialin other environments. Improved logging to clarify credential selection.Async credential retrieval:
src/ContentProcessor/src/libs/utils/azure_credential_utils.pyandsrc/ContentProcessor/src/libs/utils/credential_util.py: Updatedget_async_bearer_token_provider()to callget_async_azure_credential()synchronously instead of awaiting it, reflecting that the credential function is no longer async. [1] [2]Test updates:
src/tests/ContentProcessor/utils/test_azure_credential_utils.py: Updated tests to setAPP_ENVto "dev" to match the new credential selection logic.src/tests/ContentProcessor/utils/test_azure_credential_utils_extended.py: SetAPP_ENVto "dev" in relevant tests and updated mocks to match the new (non-async) credential retrieval. [1] [2]Does this introduce a breaking change?
Golden Path Validation
Deployment Validation
What to Check
Verify that the following are valid
Other Information