[App Config] Sanitize resource group name in data-plane test recordings - #33906
Conversation
Register a recording processor that rewrites the reused live resource group (AZURE_CLI_TEST_DEV_RESOURCE_GROUP_NAME) to a neutral stub, and default get_test_resource_group() to that stub during playback, so environment-specific resource group names are kept out of checked-in cassettes.
|
Hi Christine Wanjau (@ChristineWanjau), |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
This PR updates the az appconfig test infrastructure to prevent environment-specific resource group names from being persisted into App Configuration data-plane test recordings, enabling stable playback across environments.
Changes:
- Introduces a
ResourceGroupNameReplacerrecording processor (and registers it on data-plane test classes) to scrub the live dev resource group name into a deterministic stub in recordings. - Updates
get_test_resource_group()to useAZURE_CLI_TEST_DEV_RESOURCE_GROUP_NAMEfor live runs, fall back to a sanitized stub in playback, and fail fast in live mode when not configured. - Sanitizes existing App Configuration data-plane cassette YAML recordings to replace the previously recorded resource group name with the stub.
Reviewed changes
Copilot reviewed 24 out of 25 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/_test_utils.py | Adds sanitized RG stub constant, live/playback RG selection logic, and ResourceGroupNameReplacer processor registration. |
| src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/test_appconfig_kv_import_export_commands.py | Registers AppConfig-specific recording processors on scenario tests. |
| src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/test_appconfig_kv_commands.py | Registers AppConfig-specific recording processors on scenario tests; updates one live-run guidance comment. |
| src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/test_appconfig_key_validation.py | Registers AppConfig-specific recording processors on scenario tests. |
| src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/test_appconfig_json_content_type.py | Registers AppConfig-specific recording processors on scenario tests. |
| src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/test_appconfig_feature_commands.py | Registers AppConfig-specific recording processors on scenario tests. |
| src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/recordings/test_azconfig_strict_import.yaml | Sanitizes resource group name in recorded ARM interactions. |
| src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/recordings/test_azconfig_snapshot_mgmt.yaml | Sanitizes resource group name in recorded ARM interactions. |
| src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/recordings/test_azconfig_snapshot_filtering.yaml | Sanitizes resource group name in recorded ARM interactions. |
| src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/recordings/test_azconfig_kv.yaml | Sanitizes resource group name in recorded ARM interactions. |
| src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/recordings/test_azconfig_kv_set_snapshot_reference.yaml | Sanitizes resource group name in recorded ARM interactions. |
| src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/recordings/test_azconfig_kv_revision_list.yaml | Sanitizes resource group name in recorded ARM interactions. |
| src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/recordings/test_azconfig_kv_list_resolve_snapshot_references.yaml | Sanitizes resource group name in recorded ARM interactions. |
| src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/recordings/test_azconfig_key_validation.yaml | Sanitizes resource group name in recorded ARM interactions. |
| src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/recordings/test_azconfig_json_content_type.yaml | Sanitizes resource group name in recorded ARM interactions. |
| src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/recordings/test_azconfig_import_export.yaml | Sanitizes resource group name in recorded ARM interactions. |
| src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/recordings/test_azconfig_import_export_respect_both_schemas_naming_conventions.yaml | Sanitizes resource group name in recorded ARM interactions. |
| src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/recordings/test_azconfig_import_export_new_fm_schema.yaml | Sanitizes resource group name in recorded ARM interactions. |
| src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/recordings/test_azconfig_import_export_naming_conventions.yaml | Sanitizes resource group name in recorded ARM interactions. |
| src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/recordings/test_azconfig_import_export_kvset.yaml | Sanitizes resource group name in recorded ARM interactions. |
| src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/recordings/test_azconfig_feature.yaml | Sanitizes resource group name in recorded ARM interactions. |
| src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/recordings/test_azconfig_feature_telemetry.yaml | Sanitizes resource group name in recorded ARM interactions (including telemetry resource IDs). |
| src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/recordings/test_azconfig_feature_namespacing.yaml | Sanitizes resource group name in recorded ARM interactions. |
| src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/recordings/test_azconfig_feature_filter.yaml | Sanitizes resource group name in recorded ARM interactions. |
| src/azure-cli/azure/cli/command_modules/appconfig/tests/latest/recordings/test_appconfig_to_appconfig_import_export.yaml | Sanitizes resource group name in recorded ARM interactions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
Live test results —
|
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
Live test results —
|
There was a problem hiding this comment.
Automated review summary — PR #33906
CI checks: ✅ all 56 completed checks passed.
Live test (azdev test --live --series, changed test files only): ❌ FAIL (exit 1)
The live-test run against appconfig module tests failed with an empty/non-JSON
response body while parsing an error from the App Configuration service:
azure/appconfiguration/_generated/_operations/_operations.py:1443: in get_key_value
error = _deserialize(_models.Error, response.json())
...
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
This occurred in test_appconfig_feature_commands.py while calling
appconfig feature set --endpoint {endpoint} --auth-mode login .... The
get_configuration_setting call received a response body that could not be
parsed as JSON when the SDK tried to deserialize an error payload — likely an
unexpected empty/non-JSON error response from the (possibly sanitized) test
recording, or a live-service issue surfaced only under --auth-mode login.
Since this PR is from a fork, the regenerated recording
(test_azconfig_feature.yaml) was not pushed automatically — please
download it from the workflow artifact live-test-pr-33906 and commit it to
cwanjau/sanitizeResourceGroup if it reflects the correct sanitized behavior,
or investigate/fix the underlying appconfig feature set error-handling path
if the failure is a real regression.
Full details: https://github.com/Azure/issue-sentinel/actions/runs/32466934829
Please address the live-test failure above; CI is otherwise green.
🤖 PR Validation — ️✔️ All clear
Description
App Configuration data-plane tests use Microsoft Entra ID (
--auth-mode login) against stores created with local authentication disabled, which requires the recording principal to hold App Configuration Data Owner on a resource group. Recording against such a group caused the environment-specific resource group name to be baked into the checked-in cassettes.This change:
ResourceGroupNameReplacer) that rewrites the reused live resource group (from the standardAZURE_CLI_TEST_DEV_RESOURCE_GROUP_NAME) to a neutral stub in the recordings, and registers it on the data-plane test classes.get_test_resource_group()to that same stub during playback so requests match the sanitized cassettes, and fails fast (only in live mode) when no resource group is provided.Management-plane test recordings are intentionally left untouched.
Testing Guide
Data-plane suite: 20 passed / 3 skipped (live-only). Management suite: 10 passed / 5 skipped. No regressions.
History Notes
[Component Name]
az appconfig: Keep environment-specific resource group names out of data-plane test recordings (test-only change).