Skip to content

Set bounds for RetryPolicyOptions#2187

Merged
srnagar merged 5 commits intomicrosoft:mainfrom
srnagar:retry-bounds
Mar 25, 2026
Merged

Set bounds for RetryPolicyOptions#2187
srnagar merged 5 commits intomicrosoft:mainfrom
srnagar:retry-bounds

Conversation

@srnagar
Copy link
Member

@srnagar srnagar commented Mar 24, 2026

What does this PR do?

This pull request introduces a safeguard to the retry policy configuration in BaseAzureService to prevent excessive retries, and adds corresponding unit tests to verify this behavior. The main focus is to ensure that the maximum number of retries does not exceed 10, even if a higher value is specified.

Retry Policy Enforcement:

  • Updated ConfigureRetryPolicy in BaseAzureService to cap clientOptions.Retry.MaxRetries at 10, regardless of the value provided in RetryPolicyOptions. This prevents the system from being configured with an excessive number of retries, which could lead to service rate limiting the client.

Testing Improvements:

  • Added a new unit test ConfigureRetryPolicy_CapsMaxRetriesAt10 in BaseAzureServiceTests to verify that the maximum retries are capped at 10 when a higher value is specified.
  • Exposed a public wrapper method ConfigureRetryPolicyPublic in the test subclass to facilitate testing of the protected ConfigureRetryPolicy method.

GitHub issue number?

[Link to the GitHub issue this PR addresses]

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

Copy link
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

Caps Azure SDK retry policy MaxRetries to prevent excessively large retry configurations and adds tests + changelog entry to document/verify the behavior.

Changes:

  • Enforce an upper bound of 10 for clientOptions.Retry.MaxRetries in BaseAzureService.ConfigureRetryPolicy.
  • Add a unit test to verify retry cap behavior via a test-only public wrapper.
  • Add a changelog entry describing the retry bounds change.

Reviewed changes

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

File Description
servers/Azure.Mcp.Server/changelog-entries/1774384466055.yaml Documents the retry policy bounds change in the Azure MCP Server changelog.
core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Services/Azure/BaseAzureServiceTests.cs Adds a unit test to validate MaxRetries is capped at 10.
core/Azure.Mcp.Core/src/Services/Azure/BaseAzureService.cs Implements the cap of MaxRetries to 10 in retry configuration.

@srnagar srnagar marked this pull request as draft March 24, 2026 21:53
@srnagar srnagar marked this pull request as ready for review March 25, 2026 16:27
@github-project-automation github-project-automation bot moved this from Untriaged to In Progress in Azure MCP Server Mar 25, 2026
@srnagar srnagar enabled auto-merge (squash) March 25, 2026 16:29
@srnagar srnagar merged commit d94290a into microsoft:main Mar 25, 2026
15 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Azure MCP Server Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants