{Core} Fix bug in deprecation register when action argument is missing#32104
{Core} Fix bug in deprecation register when action argument is missing#32104
Conversation
️✔️AzureCLI-FullTest
|
️✔️AzureCLI-BreakingChangeTest
|
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a KeyError bug in the deprecation register when registering breaking changes for arguments that have an implicit action. The fix uses the safer .get() method to handle missing action keys, allowing the system to gracefully handle arguments without explicit actions.
- Replace dictionary access with
.get()method to safely retrieve action value - Handle cases where arguments have implicit actions by allowing
Noneto be passed - Improve robustness of the breaking change registration system
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR. Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
Related command
Description
This PR addresses a
KeyErrorthat occurred when registering an upcoming breaking change on an argument with an implicit action. The issue is resolved by using the.get()method to safely returnNoneif the key does not exist.Additionally,
_argument_breaking_change_actionacceptsNoneas a valid action. In such cases, the base action class defaults toargparse.Action, which raises aNotImplementedErrorwhen its__call__method is invoked. TheArgumentBreakingChangeActionclass catches this exception and falls back to behaving like a store action.This behavior aligns with the implementation in Knack:
https://github.com/microsoft/knack/blob/fb5699615a3c8b93c6bf8068306709af1c37a079/knack/arguments.py#L163-L216.
This will resolve the comments in code in #32070.
Testing Guide
History Notes
[Component Name 1] BREAKING CHANGE:
az command a: Make some customer-facing breaking change[Component Name 2]
az command b: Add some customer-facing featureThis 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.