{Role} Escape datetime help percent signs#33424
Conversation
|
Validation for Azure CLI Full Test Starting...
Thanks for your contribution! |
|
Hi @rohan-patnaik, |
|
Validation for Breaking Change Starting...
Thanks for your contribution! |
|
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>
|
|
Thank you for your contribution @rohan-patnaik! We will review the pull request and get back to you soon. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates CLI help strings to properly escape percent (%) sequences so argparse-style interpolation doesn’t treat date/time format tokens (e.g., %Y) as formatting placeholders.
Changes:
- Escaped
%in thead sp create-for-rbac--display-namehelp text. - Escaped
%in the role assignment changelogstart_time/end_timehelp template.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| help='Display name of the service principal. If not present, default to azure-cli-%%Y-%%m-%%d-%%H-%%M-%%S ' | ||
| 'where the suffix is the time of creation.') |
There was a problem hiding this comment.
@copilot-pull-request-reviewer addressed in ebf2c90: changed the sentence to use “defaults to” and kept the help text tidy.
| help='Include extra assignments to the groups of which the user is a member (transitively).') | ||
|
|
||
| time_help = 'The {} of the query in the format of %Y-%m-%dT%H:%M:%SZ, e.g. 2000-12-31T12:59:59Z. Defaults to {}' | ||
| time_help = 'The {} of the query in the format of %%Y-%%m-%%dT%%H:%%M:%%SZ, e.g. 2000-12-31T12:59:59Z. Defaults to {}' |
There was a problem hiding this comment.
@copilot-pull-request-reviewer addressed in ebf2c90: changed the wording to “The {} for the query” so the generated help reads more naturally.
Fixes #33409
Summary
This escapes the literal datetime
%tokens in role command help text.Why
Python 3.14 validates argparse help strings more strictly. The
ad sp create-for-rbacandrole assignment list-changelogshelp text used examples like%Y-%m-%ddirectly, which argparse treats as printf-style formatting and raisesValueError: badly formed help string.Escaping these as
%%Y,%%m, and so on keeps the rendered help text the same while avoiding the parser crash.Test plan
src/azure-cli/azure/cli/command_modules/role/_params.pyand validated the edited help strings withargparse.ArgumentParser(...).format_help().git diff --check