Skip to content

[monitor-control-service] Fix invalid escape sequence SyntaxWarning in data-collection rule create example - #10532

Open
nabeleon94 wants to merge 1 commit into
Azure:mainfrom
nabeleon94:amcs-fix-invalid-escape-warning
Open

nabeleon94 wants to merge 1 commit into
Azure:mainfrom
nabeleon94:amcs-fix-invalid-escape-warning

Conversation

@nabeleon94

@nabeleon94 nabeleon94 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🤖 PR Validation — ❌ Action needed

Breaking Changes Suppressions
❌ 1 ️✔️ None
❌Azure CLI Extensions Breaking Change Test
❌fleet
rule cmd_name rule_message suggest_message
❌ 1012 - SubgroupRemove fleet network sub group fleet network removed please confirm sub group fleet network removed
⚠️ 1014 - SubgroupPropRemove fleet clustermeshprofile sub group fleet clustermeshprofile removed property deprecate_info_redirect
⚠️ 1014 - SubgroupPropRemove fleet clustermeshprofile sub group fleet clustermeshprofile removed property deprecate_info_target
⚠️ 1003 - CmdPropAdd fleet clustermeshprofile apply cmd fleet clustermeshprofile apply added property is_preview
⚠️ 1003 - CmdPropAdd fleet clustermeshprofile create cmd fleet clustermeshprofile create added property is_preview
⚠️ 1003 - CmdPropAdd fleet clustermeshprofile delete cmd fleet clustermeshprofile delete added property is_preview
⚠️ 1003 - CmdPropAdd fleet clustermeshprofile list cmd fleet clustermeshprofile list added property is_preview
⚠️ 1003 - CmdPropAdd fleet clustermeshprofile list-members cmd fleet clustermeshprofile list-members added property is_preview
⚠️ 1003 - CmdPropAdd fleet clustermeshprofile show cmd fleet clustermeshprofile show added property is_preview
⚠️ 1003 - CmdPropAdd fleet clustermeshprofile wait cmd fleet clustermeshprofile wait added property is_preview
⚠️ 1003 - CmdPropAdd fleet gate approve cmd fleet gate approve added property is_preview
⚠️ 1003 - CmdPropAdd fleet gate list cmd fleet gate list added property is_preview
⚠️ 1003 - CmdPropAdd fleet gate show cmd fleet gate show added property is_preview
⚠️ 1003 - CmdPropAdd fleet gate update cmd fleet gate update added property is_preview

Fixes #10531

Related command

az monitor data-collection rule create (and every az monitor ... command, since the extension module is imported while building the command table)

Description

With Python 3.12+ (e.g. Azure CLI 2.91.0), any az monitor help/command prints:

.../azext_amcs/aaz/latest/monitor/data_collection/rule/_create.py:21: SyntaxWarning: "\s" is an invalid escape sequence. ...

The class docstring for monitor data-collection rule create contains the example path "C:\samples\dcrEx1.json" in a regular (non-raw) string, so \s is an invalid escape. This escapes the backslashes (C:\\samples\\dcrEx1.json), the same way the sibling _update.py already writes \\Process(_Total)\\Thread Count. The rendered help text is unchanged.

Also bumps the extension to 1.2.1 with a HISTORY entry.

This is the only invalid escape sequence in the extension (checked by compiling every .py under src/monitor-control-service with warnings as errors).

Testing

  • Before: python -W error::SyntaxWarning -c "import azext_amcs.aaz.latest.monitor.data_collection.rule._create" fails with SyntaxError: invalid escape sequence '\s'.
  • After: the import succeeds with warnings as errors, and Create.__doc__ (the help text) is byte-identical to before. It still shows --rule-file "C:\samples\dcrEx1.json".
  • Tested with Python 3.13 and azure-cli-core.

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? The changed file is # pylint: skip-file / # flake8: noqa generated code. Only a string literal changed.
  • Have you run python scripts/ci/test_index.py -q locally? Not applicable: src/index.json is not modified.
  • My extension version conforms to the Extension version schema (patch bump 1.2.0 → 1.2.1).

Copilot AI balanced review requested due to automatic review settings October 28, 2026 14:36
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@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 Oct 28, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the change addressing the Python 3.12+ invalid-escape warning.

No open issues 🎉

What changed in this PR

Fixes the invalid-escape SyntaxWarning emitted when the monitor-control-service extension loads for az monitor commands on Python 3.12+, addressing #10531 without changing rendered help text.

Changes:

  • Escapes backslashes in the data collection rule creation example.
  • Bumps the extension version to 1.2.1 and documents the fix.
File Description
src/​monitor-control-service/​setup.py Bumps the extension version to 1.2.1.
src/​monitor-control-service/​HISTORY.rst Adds a release note describing the warning fix.
src/​monitor-control-service/​azext_amcs/​aaz/​latest/​monitor/​data_collection/​rule/​_create.py Escapes the example path’s backslashes while preserving help output.

Review effort: Balanced

@nabeleon94

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@yonzhan

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@isra-fel

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@isra-fel
Yeming Liu (isra-fel) enabled auto-merge (squash) November 23, 2026 07:30
@nabeleon94

Copy link
Copy Markdown
Contributor Author

Thanks for the review and the /azp run, Yeming Liu (@isra-fel)! I looked at the failing Integration Tests jobs. They don't look related to this change, which only touches a help docstring plus the version/HISTORY bump:

  • azext_amcs: 3 scenario tests fail on cassette playback. The test SDK now requests resource groups with api-version=2024-11-01, but the existing recordings on main (e.g. test_amcs_data_collection_endpoint.yaml) were made with 2022-09-01.
  • azext_fleet: 4 scenario tests fail with the same playback mismatch. This PR doesn't touch fleet.

Re-recording the amcs cassettes needs a live subscription, so I've left them alone. I'm happy to adjust anything if you'd like.

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

Labels

act-observability-squad Auto-Assign Auto assign by bot customer-reported Issues that are reported by GitHub users external to the Azure organization. Monitor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python SyntaxWarning from monitor-control-service appears across az monitor command groups

6 participants