Skip to content

{Misc.} Escape percent sign to comply with Python 3.14's argparse#33087

Open
jiasli wants to merge 1 commit intoAzure:devfrom
jiasli:escape-percent
Open

{Misc.} Escape percent sign to comply with Python 3.14's argparse#33087
jiasli wants to merge 1 commit intoAzure:devfrom
jiasli:escape-percent

Conversation

@jiasli
Copy link
Copy Markdown
Member

@jiasli jiasli commented Mar 27, 2026

Related command
az ad sp create-for-rbac
az vmss update

Description
Fix #32832
Fix #32356

Python 3.14's argparse now validates help strings via %-formatting (python/cpython#124899), raising ValueError: badly formed help string when a help string contains an unescaped %. Per the argparse docs, literal % must be escaped as %%.

This PR escapes all unescaped % characters in argparse help strings across command modules.

Changes

Module Occurrences Pattern
role 2 %Y-%m-%d date format specifiers
vm 4 Default: 20%, --% operator
vm/aaz (vmss _create, _update, _patch) 9 is 20%.
acr 1 %Y-%m-%dT%H:%M:%SZ date format
appconfig 7 the '%' character
containerapp 1 %2C URL-encoded comma in URL
netappfiles 1 % of RAM
monitor (metrics, autoscale) 3 %2528, %2 URL-encoded values

Testing Guide

These are help string-only changes with no behavioral impact. The fix can be verified by running any of the previously failing commands on Python 3.14:

az ad sp create-for-rbac --help
az vmss update --help

Additional information

🤖 This PR is assisted by VS Code GitHub Copilot, with Claude Opus 4.6 Medium model, and human-verified.

Prompt:

Fix #32832 and #32356 and all related errors caused by %. The root cause analysis is in those issues.

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

azure-client-tools-bot-prd bot commented Mar 27, 2026

️✔️AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.13
️✔️acs
️✔️latest
️✔️3.12
️✔️3.13
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.13
️✔️ams
️✔️latest
️✔️3.12
️✔️3.13
️✔️apim
️✔️latest
️✔️3.12
️✔️3.13
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.13
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️aro
️✔️latest
️✔️3.12
️✔️3.13
️✔️backup
️✔️latest
️✔️3.12
️✔️3.13
️✔️batch
️✔️latest
️✔️3.12
️✔️3.13
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.13
️✔️billing
️✔️latest
️✔️3.12
️✔️3.13
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.13
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.13
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.13
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.13
️✔️config
️✔️latest
️✔️3.12
️✔️3.13
️✔️configure
️✔️latest
️✔️3.12
️✔️3.13
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.13
️✔️container
️✔️latest
️✔️3.12
️✔️3.13
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.13
️✔️core
️✔️latest
️✔️3.12
️✔️3.13
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.13
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.13
️✔️dls
️✔️latest
️✔️3.12
️✔️3.13
️✔️dms
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.13
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.13
️✔️find
️✔️latest
️✔️3.12
️✔️3.13
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.13
️✔️identity
️✔️latest
️✔️3.12
️✔️3.13
️✔️iot
️✔️latest
️✔️3.12
️✔️3.13
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.13
️✔️lab
️✔️latest
️✔️3.12
️✔️3.13
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️maps
️✔️latest
️✔️3.12
️✔️3.13
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.13
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.13
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.13
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.13
️✔️network
️✔️latest
️✔️3.12
️✔️3.13
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.13
️✔️postgresql
️✔️latest
️✔️3.12
️✔️3.13
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.13
️✔️profile
️✔️latest
️✔️3.12
️✔️3.13
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.13
️✔️redis
️✔️latest
️✔️3.12
️✔️3.13
️✔️relay
️✔️latest
️✔️3.12
️✔️3.13
️✔️resource
️✔️latest
️✔️3.12
️✔️3.13
️✔️role
️✔️latest
️✔️3.12
️✔️3.13
️✔️search
️✔️latest
️✔️3.12
️✔️3.13
️✔️security
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.13
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.13
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.13
️✔️sql
️✔️latest
️✔️3.12
️✔️3.13
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.13
️✔️storage
️✔️latest
️✔️3.12
️✔️3.13
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.13
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.13
️✔️util
️✔️latest
️✔️3.12
️✔️3.13
️✔️vm
️✔️latest
️✔️3.12
️✔️3.13

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

Hi @jiasli,
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

azure-client-tools-bot-prd bot commented Mar 27, 2026

️✔️AzureCLI-BreakingChangeTest
️✔️Non Breaking Changes

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Mar 27, 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>

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

This PR updates Azure CLI argument help strings to escape literal % characters (as %%) so command loading/help rendering works under Python 3.14’s stricter argparse help-string validation.

Changes:

  • Escaped % in date-format examples (e.g., %Y-%m-%d...) to prevent ValueError: badly formed help string.
  • Escaped % in percentage-related help text (e.g., 20%) and PowerShell --% operator references.
  • Escaped % in URL-encoded examples (e.g., %2C, %2528) used in help text.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/azure-cli/azure/cli/command_modules/role/_params.py Escapes % in date/time format examples used in help strings.
src/azure-cli/azure/cli/command_modules/vm/_params.py Escapes % in help strings referencing defaults like 20% and --% operator.
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vmss/_create.py Escapes % in rolling upgrade policy help text (AAZ).
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vmss/_patch.py Escapes % in rolling upgrade policy help text (AAZ).
src/azure-cli/azure/cli/command_modules/vm/aaz/latest/vmss/_update.py Escapes % in rolling upgrade policy help text (AAZ).
src/azure-cli/azure/cli/command_modules/acr/_params.py Escapes % in timestamp format examples for token expiration help.
src/azure-cli/azure/cli/command_modules/appconfig/_params.py Escapes % in help text that describes % character restrictions.
src/azure-cli/azure/cli/command_modules/containerapp/_params.py Escapes % in URL examples in help text.
src/azure-cli/azure/cli/command_modules/netappfiles/custom.py Escapes % in “% of RAM” help text.
src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/metrics/_list.py Escapes % in URL-encoding examples within metric filter help text.
src/azure-cli/azure/cli/command_modules/monitor/aaz/latest/monitor/autoscale/_show_predictive_metric.py Escapes % in URL-encoding examples within metric name help text.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

act-identity-squad act-observability-squad Auto-Assign Auto assign by bot Compute az vm/vmss/image/disk/snapshot ContainerApp Graph (doesn't work with label-triggered comments; use Graph.Microsoft instead) az ad NetAppFiles az netappfiles

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Value error on "az ad sp create-for-rbac" Error badly formed help string with Python v3.14.0

6 participants