Repository navigation
[KeyVault] Fix error message to reference the actual vault name option - #34220
Yeming Liu (isra-fel) wants to merge 4 commits into
Conversation
Co-authored-by: isra-fel <11371776+isra-fel@users.noreply.github.com>
Co-authored-by: isra-fel <11371776+isra-fel@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
The focused implementation matches command registration behavior and includes appropriate tests.
0 open findings
What changed in this PR
Fixes Key Vault validation errors to display the command’s actual vault-name options.
Changes:
- Dynamically resolves registered vault-name aliases with a safe fallback.
- Adds validator coverage for aliases, fallback, exclusivity, and success paths.
| File | Description |
|---|---|
_validators.py |
Builds accurate vault/HSM validation messages. |
tests/latest/test_validators.py |
Tests updated validator behavior. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
|
🔔 Routing this PR to @Azure/act-identity-squad. |
There was a problem hiding this comment.
Review
All 55 upstream checks passed on c32240f60b59. The change is scoped to validator error wording; no request/response fields or service output changed, and no recording update is indicated by this diff.
Scenario coverage to verify
The assertions in src/azure-cli/azure/cli/command_modules/keyvault/tests/latest/test_validators.py exercise registered-option variants, fallback, mutual exclusion and single-name success. They construct their own command metadata, however, rather than invoke the command that reproduces #17923. Passing these tests does not establish that az keyvault purge without arguments emits Please specify --name/-n or --hsm-name. through the real parser and validator chain.
Add a command-level regression to that test file using the repository's command-loading/invocation harness, and verify the exact error before human approval. Cover recover/show-deleted as the description claims, plus a --vault-name command such as private-link-resource list to confirm its wording remains unchanged. Rerun the focused keyvault validator tests and the command-invocation regression; this is deterministic validation and need not contact Azure.
Test validation
- Agent live test: Not run; this is a review-only PR. Check author-provided test evidence and upstream CI separately.
- Regression coverage: For
keyvault: 1 focused test file(s) changed. Scenario coverage is unverified; review the issue's required conditions, test setup, and assertions before approval. No linked issue was found in the PR timeline; inspect the source issue and its required scenario manually.
The description references #17923, which was inspected separately: its required scenario is the no-argument purge error, not an ARM operation. Author-provided evidence consists of the changed unit assertions and the testing guide; neither is an Agent live run.
Risk assessment
0/100 · Low · High confidence
The Low rating reflects the detected change scope with no elevated security, reliability, customer, operational, dependency, sovereign-cloud, generated-output, or cross-component signal.
- Change scope: 2 changed files, 80 changed lines (
+77/-3), including 1 production file. - Affected components:
keyvault - Risk drivers: No elevated risk signal was detected.
- Regression evidence: Changed regression tests are included, reducing risk.
- Confidence: High because changed-line patches were available for every production file.
- Required review: No additional owning-squad review signal was detected.
Posted by x-engineering-agent (Reviewer)
|
🔔 Routing this PR to @Azure/act-identity-squad. |
🤖 PR Validation — ️✔️ All clear
Related command
az keyvault purge,az keyvault recover,az keyvault show-deleted,az keyvault show,az keyvault delete,az keyvault createDescription
These commands expose the vault name as
--name/-n, but the validators hard-coded--vault-namein their errors, pointing users at a non-existent option:_validators.py: added_get_vault_name_options(ns), which reads theoptions_listactually registered for thevault_nameargument on the current command and falls back to--vault-namewhen it can't be resolved.validate_vault_name_and_hsm_nameandvalidate_deleted_vault_or_hsm_namebuild their "please specify" / "mutually exclusive" messages from it, so commands registering--vault-name(e.g.az keyvault private-link-resource) keep the existing wording.tests/latest/test_validators.pycovering the--name/-n,--vault-name, fallback, and success paths.Testing Guide
History Notes
[Key Vault]
az keyvault purge/recover/show-deleted: Fix error message to reference--name/-ninstead of the non-existent--vault-nameThis checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.