Skip to content

Improve Resource Health error handling#2577

Open
chidozieononiwu wants to merge 2 commits intomicrosoft:mainfrom
chidozieononiwu:Error409InResourceHealth
Open

Improve Resource Health error handling#2577
chidozieononiwu wants to merge 2 commits intomicrosoft:mainfrom
chidozieononiwu:Error409InResourceHealth

Conversation

@chidozieononiwu
Copy link
Copy Markdown
Member

@chidozieononiwu chidozieononiwu commented May 4, 2026

What does this PR do?

Add ResourceHealthRequestFailedException to preserve non-success ARM response details from Resource Health calls.

Replace raw EnsureSuccessStatusCode handling with parsed Resource Health failures, including clearer 409 Conflict guidance for provider registration or registration-in-progress cases.

Add unit coverage for availability status and service health event conflict responses.

Pre-merge Checklist

  • Required for All PRs
    • Read contribution guidelines
    • PR title clearly describes the change
    • Commit history is clean with descriptive messages (cleanup guide)
    • Added comprehensive tests for new/modified functionality
    • Created a changelog entry if the change falls among the following: new feature, bug fix, UI/UX update, breaking change, or updated dependencies. Follow the changelog entry guide
  • For MCP tool changes:
    • One tool per PR: This PR adds or modifies only one MCP tool for faster review cycles
    • Updated servers/Azure.Mcp.Server/README.md and/or servers/Fabric.Mcp.Server/README.md documentation
    • Validate README.md changes running the script ./eng/scripts/Process-PackageReadMe.ps1. See Package README
    • For new or modified tool descriptions, ran ToolDescriptionEvaluator and obtained a score of 0.4 or more and a top 3 ranking for all related test prompts
    • For tools with new names, including new tools or renamed tools, update consolidated-tools.json
    • For renamed tools, follow the Tool Rename Checklist and tag the PR with the breaking-change label
    • For new tools associated with Azure services or publicly available tools/APIs/products, add URL to documentation in the PR description
  • Extra steps for Azure MCP Server tool changes:
    • Updated command list in servers/Azure.Mcp.Server/docs/azmcp-commands.md
    • Ran ./eng/scripts/Update-AzCommandsMetadata.ps1 to update tool metadata in azmcp-commands.md (required for CI)
    • Updated test prompts in servers/Azure.Mcp.Server/docs/e2eTestPrompts.md
    • 👉 For Community (non-Microsoft team member) PRs:
      • Security review: Reviewed code for security vulnerabilities, malicious code, or suspicious activities before running tests (crypto mining, spam, data exfiltration, etc.)
      • Manual tests run: added comment /azp run mcp - pullrequest - live to run Live Test Pipeline

Copilot AI review requested due to automatic review settings May 4, 2026 22:16
@chidozieononiwu chidozieononiwu requested a review from a team as a code owner May 4, 2026 22:16
@github-project-automation github-project-automation Bot moved this to Untriaged in Azure MCP Server May 4, 2026
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.

Adds a dedicated exception type for Azure Resource Health non-success responses and centralizes HTTP response handling to preserve ARM error details (including improved 409 Conflict guidance), with new unit tests validating conflict behavior for availability status and service health event list flows.

Changes:

  • Introduced ResourceHealthRequestFailedException to retain status code, error code/message, and raw response content.
  • Replaced EnsureSuccessStatusCode() with a shared EnsureResourceHealthSuccessAsync(...) that parses ARM error payloads and throws typed exceptions.
  • Added unit tests covering 409 Conflict scenarios for list operations and command-level error mapping.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tools/Azure.Mcp.Tools.ResourceHealth/src/Services/ResourceHealthService.cs Centralizes failure parsing/throwing and replaces raw EnsureSuccessStatusCode() calls.
tools/Azure.Mcp.Tools.ResourceHealth/src/Services/ResourceHealthRequestFailedException.cs New exception type to carry ARM failure details and build an error message.
tools/Azure.Mcp.Tools.ResourceHealth/src/Commands/BaseResourceHealthCommand.cs Maps the new exception to status codes and conflict-specific messaging.
tools/Azure.Mcp.Tools.ResourceHealth/tests/.../ResourceHealthServiceSsrfValidationTests.cs Adds a unit test asserting 409 parsing and the new exception details surface correctly.
tools/Azure.Mcp.Tools.ResourceHealth/tests/.../ServiceHealthEventsListCommandTests.cs Adds command test for 409 Conflict response handling/messaging.
tools/Azure.Mcp.Tools.ResourceHealth/tests/.../AvailabilityStatusGetCommandTests.cs Adds command test for 409 Conflict response handling/messaging.

@chidozieononiwu chidozieononiwu requested a review from a team as a code owner May 4, 2026 22:42
@chidozieononiwu chidozieononiwu force-pushed the Error409InResourceHealth branch 2 times, most recently from d3bf5cd to 90fffb2 Compare May 5, 2026 20:29
Copy link
Copy Markdown
Contributor

@jongio jongio left a comment

Choose a reason for hiding this comment

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

The PR's approach is solid - centralizing error handling via EnsureResourceHealthSuccessAsync and adding ResourceHealthRequestFailedException for non-422 failures is clean. The 409 Conflict guidance is useful.

However, CI is failing across all platforms due to a property name mismatch: the exception class declares ErrorMessage (line 19 of the new file) but BaseResourceHealthCommand.GetErrorMessage and the SSRF test both reference ErrorDetails. This needs to be reconciled - either rename the property back to ErrorDetails or update the two call sites.

Add ResourceHealthRequestFailedException to preserve non-success ARM response details from Resource Health calls.

Replace raw EnsureSuccessStatusCode handling with parsed Resource Health failures, including clearer 409 Conflict guidance for provider registration or registration-in-progress cases.

Add unit coverage for availability status and service health event conflict responses.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

3 participants