Skip to content

[AzureBackup] Fix exception types for correct telemetry classification#2841

Merged
shrja-ms merged 4 commits into
microsoft:mainfrom
shrja-ms:user/azurebackup-fix-exception-telemetry-classification
Jun 10, 2026
Merged

[AzureBackup] Fix exception types for correct telemetry classification#2841
shrja-ms merged 4 commits into
microsoft:mainfrom
shrja-ms:user/azurebackup-fix-exception-telemetry-classification

Conversation

@shrja-ms

@shrja-ms shrja-ms commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes telemetry misclassification where user-input validation errors were tagged as \McpToolBug\ instead of \Customer.

The ADX telemetry classifier treats \InvalidOperationException\ as \McpToolBug. Several throws in the Azure Backup service layer use \InvalidOperationException\ for what are actually user-input validation errors (unsupported policy type, DPP not supporting update, ambiguous datasource match, schedule/retention not applicable). These inflate the MCP bug count — e.g., 1 hit on \policy_update\ (beta.16, Jun 5) was classified as a tool bug when it was a user passing an unsupported policy type.

Changes

File Change Rationale
\RsvBackupOperations.cs\ 7× \InvalidOperationException\ → \ArgumentException\ Unsupported policy type, schedule/retention not applicable, ambiguous datasource — all user-input errors
\AzureBackupService.cs\ 1× \InvalidOperationException\ → \ArgumentException\ DPP policy update not supported — user chose wrong vault type
\DppBackupOperations.cs\ 1× \InvalidOperationException\ → \KeyNotFoundException\ Job not found after FormatException fallback — proper 'not found' semantics
\PolicyUpdateCommand.cs\ Removed \InvalidOperationException\ branches from \GetErrorMessage/\GetStatusCode\ No longer thrown from service layer
\PolicyUpdateCommandTests.cs\ Updated mocks and assertions Match new exception types
\AzureBackupCommandTests.cs\ Updated live test assertion \ArgumentException\ instead of \InvalidOperationException\
\changelog-entries/*.yml\ Changelog entry Documents the fix

Telemetry Impact

  • \ArgumentException\ → classifier sees \400 BadRequest\ → Customer bucket ✅
  • \KeyNotFoundException\ → classifier sees \404 NotFound\ → Customer bucket ✅
  • \InvalidOperationException\ (was) → classifier sees → McpToolBug bucket ❌

This change ensures user-facing validation errors are correctly classified as Customer errors in the ADX dashboard and weekly telemetry reports.

Testing

  • \dotnet build\ ✅ — 0 warnings, 0 errors
  • Unit tests updated to use \ArgumentException\ in mocks and assertions
  • Live test assertion updated (\InvalidOperationException\ → \ArgumentException)

Invoking Livetests

Copilot submitted PRs are not trustworthy by default. Users with \write\ access to the repo need to validate the contents of this PR before leaving a comment with the text /azp run mcp - pullrequest - live. This will trigger the necessary livetest workflows to complete required validation.

shrja-ms added 2 commits June 4, 2026 11:40
Add kql-customer-queries.md (queries 14-24) covering:
- Customer identification via P360/C360 cross-cluster joins
- Subscription breakdown and customer name resolution
- Tool usage ranking and per-customer tool breakdown
- Client/editor distribution and version analysis
- Daily trend queries for dashboards
- Customer aggregation rules and known data quirks

Update SKILL.md to reference customer report workflow and
document P360_CustomerName usage (vs unreliable CustomerName).
Replace InvalidOperationException with ArgumentException for user-input
validation errors (unsupported policy type, DPP update not supported,
ambiguous datasource, schedule/retention not applicable). Replace one
InvalidOperationException with KeyNotFoundException for job-not-found
after FormatException fallback.

The ADX telemetry classifier treats InvalidOperationException as McpToolBug.
These errors are actually Customer-side (bad input, wrong vault type,
ambiguous match) and should classify as Customer (via ArgumentException ->
400) or Customer (via KeyNotFoundException -> 404).

Changes:
- RsvBackupOperations.cs: 7x InvalidOperationException -> ArgumentException
- AzureBackupService.cs: DPP update not supported -> ArgumentException
- DppBackupOperations.cs: Job not found fallback -> KeyNotFoundException
- PolicyUpdateCommand.cs: Remove InvalidOperationException error handlers
- Tests: Update exception types in mocks and assertions
Copilot AI review requested due to automatic review settings June 9, 2026 06:28
@shrja-ms shrja-ms requested review from a team as code owners June 9, 2026 06:28

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.

Pull request overview

This PR adjusts exception types in the Azure Backup tool/service layer so user-input validation failures are classified as Customer errors in telemetry (instead of being misclassified as MCP tool bugs), and updates command/test/documentation assets accordingly.

Changes:

  • Replace several InvalidOperationException throws used for input/validation scenarios with ArgumentException (and one case to KeyNotFoundException) to influence telemetry classification.
  • Simplify PolicyUpdateCommand error handling by removing InvalidOperationException-specific branches now that the service layer no longer throws them for expected validation cases.
  • Update unit/live tests and add documentation + changelog entry covering telemetry/customer reporting guidance.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tools/Azure.Mcp.Tools.AzureBackup/tests/Azure.Mcp.Tools.AzureBackup.Tests/Policy/PolicyUpdateCommandTests.cs Updates unit tests to expect ArgumentException for DPP-not-supported and unsupported policy type scenarios.
tools/Azure.Mcp.Tools.AzureBackup/tests/Azure.Mcp.Tools.AzureBackup.Tests/AzureBackupCommandTests.cs Updates live test assertion/comment to expect ArgumentException for DPP policy update not supported.
tools/Azure.Mcp.Tools.AzureBackup/src/Services/RsvBackupOperations.cs Converts several validation/selection errors from InvalidOperationException to ArgumentException for telemetry classification.
tools/Azure.Mcp.Tools.AzureBackup/src/Services/DppBackupOperations.cs Changes the job-not-found-after-FormatException-fallback throw type (see review comment).
tools/Azure.Mcp.Tools.AzureBackup/src/Services/AzureBackupService.cs Throws ArgumentException (instead of InvalidOperationException) when policy update is attempted against a non-RSV vault.
tools/Azure.Mcp.Tools.AzureBackup/src/Commands/Policy/PolicyUpdateCommand.cs Removes InvalidOperationException branches from error message + status code selection.
tools/Azure.Mcp.Tools.AzureBackup/skills/azurebackup-telemetry-report/SKILL.md Expands the telemetry-report skill documentation to include customer/adoption reporting guidance and references.
tools/Azure.Mcp.Tools.AzureBackup/skills/azurebackup-telemetry-report/references/kql-customer-queries.md Adds customer/adoption KQL query reference material.
servers/Azure.Mcp.Server/changelog-entries/azurebackup-fix-exception-telemetry-classification.yml Adds a changelog entry describing the telemetry classification fix.

…eption

ListJobsAsync may return a partial list when it also hits FormatException
during enumeration. A null FirstOrDefault result does NOT reliably mean
the job is missing — it may exist beyond the enumerator break point.

Throw FormatException (not KeyNotFoundException/404) to preserve the
SDK-parse-failure semantics. This is a genuine tool limitation (tracked
in azure-sdk-for-net#59306), not a 'not found' condition.
Comment thread tools/Azure.Mcp.Tools.AzureBackup/src/Services/DppBackupOperations.cs Outdated
Move azure-sdk-for-net#59306 reference from the exception message to a
code comment. The issue link is not actionable by the user of Azure MCP.
@shrja-ms shrja-ms enabled auto-merge (squash) June 9, 2026 15:17
@shrja-ms shrja-ms merged commit 1fb90a6 into microsoft:main Jun 10, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants