Skip to content

{Role} Escape datetime help percent signs#33424

Open
rohan-patnaik wants to merge 2 commits into
Azure:devfrom
rohan-patnaik:fix-role-help-percent-escaping
Open

{Role} Escape datetime help percent signs#33424
rohan-patnaik wants to merge 2 commits into
Azure:devfrom
rohan-patnaik:fix-role-help-percent-escaping

Conversation

@rohan-patnaik
Copy link
Copy Markdown

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-rbac and role assignment list-changelogs help text used examples like %Y-%m-%d directly, which argparse treats as printf-style formatting and raises ValueError: 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

  • Parsed src/azure-cli/azure/cli/command_modules/role/_params.py and validated the edited help strings with argparse.ArgumentParser(...).format_help().
  • git diff --check

Copilot AI review requested due to automatic review settings May 22, 2026 06:59
@azure-client-tools-bot-prd
Copy link
Copy Markdown

Validation for Azure CLI Full Test Starting...

Thanks for your contribution!

@azure-client-tools-bot-prd
Copy link
Copy Markdown

Hi @rohan-patnaik,
Since the current milestone time is less than 7 days, this pr will be reviewed in the next milestone.

@azure-client-tools-bot-prd
Copy link
Copy Markdown

Validation for Breaking Change Starting...

Thanks for your contribution!

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented May 22, 2026

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link
Copy Markdown

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).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

@microsoft-github-policy-service microsoft-github-policy-service Bot added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label May 22, 2026
@microsoft-github-policy-service
Copy link
Copy Markdown
Contributor

Thank you for your contribution @rohan-patnaik! We will review the pull request and get back to you soon.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 the ad sp create-for-rbac --display-name help text.
  • Escaped % in the role assignment changelog start_time/end_time help template.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 188 to 189
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.')
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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 {}'
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot-pull-request-reviewer addressed in ebf2c90: changed the wording to “The {} for the query” so the generated help reads more naturally.

@yonzhan yonzhan assigned isra-fel and unassigned jiasli May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

act-identity-squad Auto-Assign Auto assign by bot customer-reported Issues that are reported by GitHub users external to the Azure organization. RBAC az role

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Azure CLI crashes on Python 3.14 due to unescaped % in argparse help strings

5 participants