Skip to content

Fix Helix test result upload retries - #17256

Merged
mmitche merged 14 commits into
dotnet:mainfrom
mmitche:copilot/helix-upload-retries
Aug 6, 2026
Merged

mmitche merged 14 commits into
dotnet:mainfrom
mmitche:copilot/helix-upload-retries

Conversation

@mmitche

@mmitche mmitche commented Aug 5, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Retry transient Azure DevOps test-result upload transport failures and 5xx/429 responses.
  • Use Arcade Common retry results to combine exponential backoff with Retry-After without double delays.
  • Enable retries for test-result writes and dispose non-success responses safely.

Validation

  • dotnet test .\src\Microsoft.DotNet.Helix\Sdk.Tests\Microsoft.DotNet.Helix.Sdk.Tests\Microsoft.DotNet.Helix.Sdk.Tests.csproj --no-restore
  • 192 tests passed

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 0b8e67d1-91bc-4a47-a405-45549fe22d6f
Copilot AI review requested due to automatic review settings August 5, 2026 18:49

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 improves reliability of Helix → Azure DevOps test-result publishing by retrying transient transport failures and 5xx/429 responses, while integrating Retry-After into the existing Arcade Common retry infrastructure.

Changes:

  • Add retry support for Azure DevOps test-result uploads (while keeping test-run create/complete single-attempt).
  • Extend Arcade Common retry handling to carry Retry-After information and combine it with exponential backoff.
  • Document the new retry behavior in the Helix SDK readme.

Reviewed changes

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

Show a summary per file
File Description
src/Microsoft.DotNet.Helix/Sdk/Readme.md Documents the new test-result upload retry behavior.
src/Microsoft.DotNet.Helix/JobMonitor/Services/AzureDevOpsService.cs Enables retries for test-result publishing.
src/Microsoft.DotNet.Helix/AzureDevOpsTestPublisher/RetryHelper.cs Switches local retry helper to Arcade Common retry infrastructure.
src/Microsoft.DotNet.Helix/AzureDevOpsTestPublisher/Microsoft.DotNet.Helix.AzureDevOpsTestPublisher.csproj Adds a project reference to Microsoft.Arcade.Common.
src/Microsoft.DotNet.Helix/AzureDevOpsTestPublisher/AzureDevOpsResultPublisher.cs Implements retry logic for transient HTTP/transport failures and uses Retry-After.
src/Microsoft.DotNet.Build.Tasks.Feed.Tests/TestDoubles/MockRetryHandler.cs Updates test retry handler to the new retry result model.
src/Common/Microsoft.Arcade.Common/IRetryHandler.cs Changes retry handler contract to support Retry-After signaling.
src/Common/Microsoft.Arcade.Common/ExponentialRetry.cs Implements Retry-After support by combining it with exponential delay.

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

Comment on lines +437 to +445
if (isTransientStatus && attempt < retryCount)
{
TimeSpan? retryAfter = GetRetryDelay(response);
_logger.LogDebug(
"Hit HTTP {StatusCode} from Azure DevOps. Retrying ({RetriesLeft} retries left).",
(int)response.StatusCode,
retryCount - attempt);
return RetryResult.Retry(retryAfter);
}

@missymessa missymessa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Review findings posted by GitHub Copilot CLI on behalf of @missymessa.

// Test-result POSTs are retried by the publisher for transient HTTP and
// transport failures. Create/complete operations remain single-attempt because
// their responses are ambiguous state-changing writes.
RetryWrites: true);

@missymessa missymessa Aug 5, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

GitHub Copilot CLI (posted on behalf of @missymessa): This re-enables retries for result and attachment POSTs even though JobMonitorRunner.Design.md explicitly says state-changing writes must not be replayed after ambiguous failures because doing so can duplicate test runs, results, or attachments. A transport failure can occur after Azure DevOps commits the request but before the response reaches the client. Please keep RetryWrites disabled unless these requests gain an idempotency/deduplication mechanism.

}
return succeeded && successfulResponse is not null
? successfulResponse
: throw new InvalidOperationException("Azure DevOps retry loop exited unexpectedly.");

@missymessa missymessa Aug 5, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

GitHub Copilot CLI (posted on behalf of @missymessa): Cancellation during ExponentialRetry's backoff is caught as TaskCanceledException and converted to a false result. This branch then throws InvalidOperationException instead of propagating OperationCanceledException; RetryHelper similarly rethrows the previous transient exception. Please preserve cancellation by rethrowing when the supplied token is canceled.

Replace remaining call sites with ExponentialRetry.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 7b0d769e-fb8b-4a7e-985d-e7f4bb3c7356
Copilot AI review requested due to automatic review settings August 5, 2026 21:03
@@ -389,79 +391,98 @@ private async Task<HttpResponseMessage> SendWithRetryAsync(
int retryCount,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No reason for this to stay at retryCount. Instead, make this attemptCount, and then this can be used directly in ExponentialRetry

{
throw;
}
catch (Exception) when (attempt < 4)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

There should be no need to check the attempt number here.

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

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

Suppressed comments (4)

src/Common/Microsoft.Arcade.Common/ExponentialRetry.cs:37

  • ExponentialRetry no longer exposes RunAsync overloads that accept Func<int, Task>. Many existing callers create ExponentialRetry directly and return true/false from the retry lambda, which will fail to compile against the new signature. Adding back bool-based overloads that forward into the RetryResult overload will preserve compatibility while still enabling Retry-After support.
        public Task<bool> RunAsync(Func<int, Task<RetryResult>> actionAsync)
        {
            return RunAsync(actionAsync, DefaultCancellationToken);
        }

src/Microsoft.DotNet.Build.Tasks.Feed.Tests/TestDoubles/MockRetryHandler.cs:31

  • If IRetryHandler keeps/retains the existing Func<int, Task> overloads for compatibility, MockRetryHandler should implement those overloads as well; otherwise any tests or helpers that pass a Task-returning lambda will no longer compile.
        public Task<bool> RunAsync(Func<int, Task<RetryResult>> actionAsync)
            => RunAsync(actionAsync, CancellationToken.None);

        public async Task<bool> RunAsync(Func<int, Task<RetryResult>> actionAsync, CancellationToken cancellationToken)
        {

src/Common/Microsoft.Arcade.Common/IRetryHandler.cs:14

  • Changing IRetryHandler.RunAsync to require Func<int, Task> is a breaking change that will not compile with existing call sites that return Task (e.g. async lambdas returning true/false). Consider keeping the original Task-based overloads and adding the RetryResult overloads alongside them so existing consumers continue to build.
    public interface IRetryHandler
    {
        Task<bool> RunAsync(
            Func<int, Task<RetryResult>> actionAsync);

src/Microsoft.DotNet.Helix/AzureDevOpsTestPublisher/AzureDevOpsResultPublisher.cs:445

  • The new retry path for HTTP 429 relies on Retry-After; if the server omits that header, the first backoff will be only 1s (3^0) instead of the prior 30s default, which can cause rapid re-throttling. Consider keeping a conservative minimum delay for 429 when Retry-After is absent.
                        bool isTransientStatus = (int)response.StatusCode >= 500
                            || response.StatusCode == HttpStatusCode.TooManyRequests;
                        if (isTransientStatus && attempt < retryCount)
                        {
                            TimeSpan? retryAfter = GetRetryDelay(response);

- **One-shot retry on entry.** When the monitor starts, it takes a snapshot of the Helix jobs for
the build and resubmits the failed work items from each completed job's latest incarnation.
Passing work items are not resubmitted; only the failed ones are.
- **Test-result upload retries.** Transient Azure DevOps transport, server, and throttling

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is not user facing behaviro and should not be included in the readme.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed. Removed this from the SDK readme since the retry policy is an internal reliability detail rather than user-facing behavior.

Preserve bool retry-handler overloads and retain the 429 backoff fallback.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 7b0d769e-fb8b-4a7e-985d-e7f4bb3c7356
Copilot AI review requested due to automatic review settings August 5, 2026 21:12

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

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

Suppressed comments (3)

src/Microsoft.DotNet.Helix/AzureDevOpsTestPublisher/AzureDevOpsResultPublisher.cs:489

  • IsTransientException doesn’t treat TaskCanceledException (the common exception type thrown by HttpClient timeouts when the caller’s cancellation token isn’t canceled) as transient. That means request timeouts won’t be retried even though this code is intended to retry transport failures.
    private static bool IsTransientException(Exception exception)
        => exception is HttpRequestException
            or TimeoutException
            or SocketException
            or IOException;

src/Microsoft.DotNet.Helix/JobMonitor/Services/AzureDevOpsService.cs:526

  • The retry filter is hard-coded to attempt < 4 even though the retry handler’s MaxAttempts is configured separately. Deriving the cutoff from MaxAttempts prevents the logic from drifting if the attempt count is tuned later.
                    catch (Exception) when (attempt < 4)

src/Microsoft.DotNet.Helix/JobMonitor/Services/HelixService.cs:410

  • The retry filter is hard-coded to attempt < 4 even though MaxAttempts is configured separately. If MaxAttempts changes, the catch filter can become inconsistent (either retrying fewer times than intended or throwing earlier than intended).
                    catch (Exception ex) when (attempt < 4)

Keep the retry handler contract change as-is for this PR.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 7b0d769e-fb8b-4a7e-985d-e7f4bb3c7356
Copilot AI review requested due to automatic review settings August 5, 2026 21:19

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

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

Suppressed comments (2)

src/Common/Microsoft.Arcade.Common/IRetryHandler.cs:14

  • The IRetryHandler.RunAsync signature change (from Func<int, Task> to Func<int, Task>) is a breaking API change for existing callers. There are multiple call sites in the repo still passing async lambdas that return bool, which will no longer compile. Consider adding adapter overloads (e.g., extension methods) that accept Func<int, Task> and forward to the new RetryResult-based APIs so existing code continues to build while new code can opt into RetryAfter-aware retries.
    public interface IRetryHandler
    {
        Task<bool> RunAsync(
            Func<int, Task<RetryResult>> actionAsync);

src/Common/Microsoft.Arcade.Common/ExponentialRetry.cs:63

  • Cancellation during the inter-attempt delay is currently swallowed (Task.Delay cancellation leads to breaking out of the loop and returning false). That can cause callers to see a generic retry failure instead of an OperationCanceledException. Consider propagating cancellation from the delay so standard cancellation semantics are preserved.
                TimeSpan delay = result.RetryAfter is TimeSpan retryAfter
                    ? TimeSpan.FromTicks(Math.Max(exponentialDelay.Ticks, retryAfter.Ticks))
                    : exponentialDelay;

                Trace.TraceInformation($"{attempt} failed. Waiting {delay} before next try.");

Pass attempt counts directly to ExponentialRetry and preserve final retry errors.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 7b0d769e-fb8b-4a7e-985d-e7f4bb3c7356
Copilot AI review requested due to automatic review settings August 5, 2026 21: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

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

Suppressed comments (5)

src/Microsoft.DotNet.Helix/AzureDevOpsTestPublisher/AzureDevOpsResultPublisher.cs:491

  • HttpClient timeouts commonly surface as TaskCanceledException (often wrapping a TimeoutException). Since TaskCanceledException isn't treated as transient here, timeouts may not be retried even though other transport failures are. Consider including TaskCanceledException in the transient exception list (while still letting explicit cancellation flow through via the earlier OperationCanceledException filter).
    private static bool IsTransientException(Exception exception)
        => exception is HttpRequestException
            or TimeoutException
            or SocketException
            or IOException;

src/Common/Microsoft.Arcade.Common/ExponentialRetry.cs:61

  • ExponentialRetry delays after every failed attempt, including the final attempt, which adds unnecessary wait time before returning failure (and can be especially noticeable when MaxAttempts is 1). Consider skipping the delay when there is no next attempt.
                TimeSpan exponentialDelay = TimeSpan.FromSeconds(
                    (Math.Pow(DelayBase, i) + DelayConstant) * randomFactor);
                TimeSpan delay = result.RetryAfter is TimeSpan retryAfter
                    ? TimeSpan.FromTicks(Math.Max(exponentialDelay.Ticks, retryAfter.Ticks))
                    : exponentialDelay;

src/Microsoft.DotNet.Helix/AzureDevOpsTestPublisher/AzureDevOpsResultPublisher.cs:406

  • With DelayBase=3 and attemptCount=10, the exponential backoff can grow to very large delays (e.g., >1 hour before the final attempt), potentially stalling result uploads for a long time during extended outages. A smaller base (e.g., 2) better bounds worst-case retry time while still backing off.
        var retryHandler = new ExponentialRetry
        {
            MaxAttempts = attemptCount,
            DelayBase = 3,
            DelayConstant = 0,

src/Microsoft.DotNet.Helix/AzureDevOpsTestPublisher/AzureDevOpsResultPublisher.cs:415

  • The retry behavior is now more complex (status-based retries with Retry-After + exponential backoff, plus transport-exception retries). There are existing unit tests for AzureDevOpsResultPublisher, but none cover the new retry paths (e.g., 429 honoring Retry-After, 5xx retry, and transient exceptions). Adding focused tests would reduce regression risk.
        bool succeeded = await retryHandler.RunAsync(
            async _ =>
            {
                Uri baseUri = _azdoParameters.CollectionUri.AbsoluteUri.EndsWith('/')
                    ? _azdoParameters.CollectionUri

src/Microsoft.DotNet.Helix/JobMonitor/Services/AzureDevOpsService.cs:531

  • When retryTransientFailures is enabled, this retries all exceptions, including HttpRequestException for non-transient 4xx responses (e.g., 400/401/403). That can turn permanent failures into repeated retries and extra delay; the retry loop should be limited to transient statuses (5xx/429) and transport exceptions.
                    catch (Exception ex)
                    {
                        lastException = ex;
                        return RetryResult.Retry();
                    }

Make ExponentialRetry check and propagate cancellation around attempts and backoff delays.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 7b0d769e-fb8b-4a7e-985d-e7f4bb3c7356
Copilot AI review requested due to automatic review settings August 5, 2026 21:58

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

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

Suppressed comments (2)

src/Microsoft.DotNet.Helix/AzureDevOpsTestPublisher/AzureDevOpsResultPublisher.cs:491

  • HttpClient is configured with a timeout (CreateHttpClient sets HttpClient.Timeout). When a request hits this timeout, HttpClient throws TaskCanceledException; currently IsTransientException doesn't treat that as transient, so timeouts won't be retried despite being a common transport failure mode.
    private static bool IsTransientException(Exception exception)
        => exception is HttpRequestException
            or TimeoutException
            or SocketException
            or IOException;

src/Common/Microsoft.Arcade.Common/ExponentialRetry.cs:67

  • ExponentialRetry delays after every failed attempt, including the final attempt. This adds an unnecessary wait even when no retry will occur (e.g., MaxAttempts=1), and also delays the failure path after the last try.
                Trace.TraceInformation($"{attempt} failed. Waiting {delay} before next try.");

                await Task.Delay(delay, cancellationToken);

Azure DevOps result publisher writes now always use the configured retry policy.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 7b0d769e-fb8b-4a7e-985d-e7f4bb3c7356
Stop before the final backoff and preserve the last failure without callback-level attempt checks.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 7b0d769e-fb8b-4a7e-985d-e7f4bb3c7356

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

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

Suppressed comments (3)

src/Microsoft.DotNet.Helix/AzureDevOpsTestPublisher/AzureDevOpsResultPublisher.cs:487

  • Transient network failures from HttpClient timeouts are commonly surfaced as OperationCanceledException/TaskCanceledException when the caller's CancellationToken is not canceled. The current transient filter won't retry those failures, and also risks retrying real cancellations if you later add OperationCanceledException without guarding on the token state.
    private static bool IsTransientException(Exception exception)
        => exception is HttpRequestException
            or TimeoutException
            or SocketException
            or IOException;

src/Common/Microsoft.Arcade.Common/ExponentialRetry.cs:60

  • ExponentialRetry delays after the final failed attempt even though no further retry will occur. This adds unnecessary latency (and can be significant when RetryAfter is large).
                if (i == MaxAttempts - 1)
                {
                    return false;
                }

src/Microsoft.DotNet.Helix/AzureDevOpsTestPublisher/AzureDevOpsResultPublisher.cs:404

  • SendWithRetryAsync now treats the passed count as the total attempt count (MaxAttempts = attemptCount). Previously the parameter represented the number of retries, so the total attempts were (retryCount + 1). This reduces the number of tries by one for all calls (e.g., DefaultRetryCount=10 becomes 10 attempts instead of 11).

This issue also appears on line 483 of the same file.

            MaxAttempts = attemptCount,

Copilot AI review requested due to automatic review settings August 5, 2026 23:56
Bound exponential backoff at 30 seconds while continuing to honor longer Retry-After guidance.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 7b0d769e-fb8b-4a7e-985d-e7f4bb3c7356

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

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

Suppressed comments (3)

src/Microsoft.DotNet.Helix/AzureDevOpsTestPublisher/AzureDevOpsResultPublisher.cs:487

  • Transient transport timeouts from HttpClient are commonly surfaced as TaskCanceledException. The current transient filter won’t retry those, and if TaskCanceledException is added later it would also accidentally swallow real cancellation unless the catch filter checks the provided CancellationToken.
    }

    private static bool IsTransientException(Exception exception)
        => exception is HttpRequestException
            or TimeoutException

src/Microsoft.DotNet.Helix/AzureDevOpsTestPublisher/AzureDevOpsResultPublisher.cs:404

  • Retry count semantics appear to have changed: the previous loop performed the initial request plus retryCount additional retries. With MaxAttempts = attemptCount, passing DefaultRetryCount now results in one fewer total attempt than before. This can reduce resilience under transient Azure DevOps failures.
        {

src/Microsoft.DotNet.Helix/JobMonitor/Services/AzureDevOpsService.cs:520

  • This retry loop always returns RetryResult.Retry() without propagating any Retry-After guidance from the underlying HTTP response. Since SendOnceAsync already awaits HonorRateLimitAsync (which can delay using Retry-After / X-RateLimit-Delay), the ExponentialRetry backoff adds an additional delay, resulting in double delays per failed attempt (contrary to the PR goal of combining exponential backoff with Retry-After without double delays).
                    catch (Exception ex) when (!cancellationToken.IsCancellationRequested)
                    {
                        lastException = ex;
                        return RetryResult.Retry();

Copilot AI review requested due to automatic review settings August 6, 2026 00:02

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

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

Suppressed comments (3)

src/Microsoft.DotNet.Helix/AzureDevOpsTestPublisher/AzureDevOpsResultPublisher.cs:476

  • HttpClient timeouts typically surface as TaskCanceledException/OperationCanceledException when the passed cancellationToken was not canceled. Those currently won't be treated as transient because IsTransientException doesn't include them, so the new retry loop can still fail without retrying on timeouts/HTTP-client timeouts.
                catch (Exception ex) when (IsTransientException(ex))
                {
                    lastException = ex;
                    _logger.LogDebug(
                        ex,
                        "Transient Azure DevOps request failure. Retrying.");
                    return RetryResult.Retry();
                }

src/Microsoft.DotNet.Helix/AzureDevOpsTestPublisher/AzureDevOpsResultPublisher.cs:17

  • The previous implementation effectively allowed 10 retries + the initial attempt (11 total attempts) when DefaultRetryCount was 10. With DefaultAttemptCount = 10 and MaxAttempts = attemptCount, the default drops to 10 total attempts, slightly reducing resiliency. If the intent is to preserve the old behavior, bump the default attempt count by 1 (or adjust how MaxAttempts is computed).
    private const int DefaultAttemptCount = 10;
    private static readonly TimeSpan s_maximumRetryDelay = TimeSpan.FromSeconds(30);

src/Microsoft.DotNet.Helix/JobMonitor/Services/AzureDevOpsService.cs:521

  • In the retry path, SendOnceAsync already calls HonorRateLimitAsync(...) (which can Task.Delay based on Retry-After / X-RateLimit-Delay) before throwing. The outer ExponentialRetry then adds its own delay, so retries can end up double-delaying and the new RetryResult.RetryAfter capability isn't being used here.
                    catch (Exception ex) when (!cancellationToken.IsCancellationRequested)
                    {
                        lastException = ex;
                        return RetryResult.Retry();
                    }

@mmitche
mmitche requested a review from premun August 6, 2026 00:56
Treat TaskCanceledException as transient unless the caller cancellation token was requested.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 7b0d769e-fb8b-4a7e-985d-e7f4bb3c7356
Copilot AI review requested due to automatic review settings August 6, 2026 14:53
Accept possible duplicate results or attachments while keeping run lifecycle writes single-attempt.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 7b0d769e-fb8b-4a7e-985d-e7f4bb3c7356

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

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

Suppressed comments (3)

src/Common/Microsoft.Arcade.Common/IRetryHandler.cs:18

  • Changing IRetryHandler.RunAsync from Func<int, Task<bool>> to Func<int, Task<RetryResult>> is a source-breaking API change for any external implementers/callers of Microsoft.Arcade.Common. If this library is consumed outside this repo, consider keeping the original overloads (or providing adapters/extension methods) and introducing the RetryResult-based API in a non-breaking way.
    public interface IRetryHandler
    {
        Task<bool> RunAsync(
            Func<int, Task<RetryResult>> actionAsync);

        Task<bool> RunAsync(
            Func<int, Task<RetryResult>> actionAsync,
            CancellationToken cancellationToken);
    }

src/Microsoft.DotNet.Helix/AzureDevOpsTestPublisher/AzureDevOpsResultPublisher.cs:17

  • DefaultAttemptCount is set to 10, but the previous DefaultRetryCount = 10 logic performed 1 initial attempt + 10 retries (11 total attempts). With ExponentialRetry.MaxAttempts = attemptCount, the new behavior reduces the total attempts by one, which may be an unintended regression in resiliency.
    private const int DefaultAttemptCount = 10;
    private static readonly TimeSpan s_maximumRetryDelay = TimeSpan.FromSeconds(30);

src/Microsoft.DotNet.Helix/AzureDevOpsTestPublisher/Model/AzureDevOpsReportingParameters.cs:11

  • Removing RetryWrites from AzureDevOpsReportingParameters is a breaking change for any consumers constructing this record, and it also removes the ability for callers to explicitly opt out of retrying write operations. If external callers depend on the old shape/behavior, consider a compatibility path (e.g., keep the parameter as obsolete or move retry policy to a separate options type).
public sealed record AzureDevOpsReportingParameters(
    Uri CollectionUri,
    string TeamProject,
    string TestRunId,
    string? AccessToken = null,
    bool UseFullyQualifiedTestName = false);

Copilot AI review requested due to automatic review settings August 6, 2026 15:00

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

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

Suppressed comments (2)

src/Common/Microsoft.Arcade.Common/IRetryHandler.cs:14

  • IRetryHandler is part of Microsoft.Arcade.Common (IsPackable=true). Changing RunAsync from Func<int, Task> to Func<int, Task> is a breaking API change for any external implementers/consumers of the package. If this is intended, ensure the package versioning/compat story accounts for it; otherwise consider introducing a new interface/type and leaving the existing contract intact.
    public interface IRetryHandler
    {
        Task<bool> RunAsync(
            Func<int, Task<RetryResult>> actionAsync);

src/Microsoft.DotNet.Helix/JobMonitor/Services/AzureDevOpsService.cs:507

  • The retry loop in SendForStringAsync can double-delay on failures: SendOnceAsync awaits HonorRateLimitAsync (which may delay per Retry-After / X-RateLimit-Delay) and then the outer ExponentialRetry will also apply its own exponential backoff delay before the next attempt. This can make retries significantly slower than intended and conflicts with the goal of combining exponential backoff with Retry-After without stacking delays.
            string result = null;
            Exception lastException = null;
            var retryHandler = new ExponentialRetry
            {
                MaxAttempts = 5,
                DelayBase = 2,
                DelayConstant = 0,
                MinRandomFactor = 1,
                MaxRandomFactor = 1,
            };

Retry OperationCanceledException only when it wraps TimeoutException and caller cancellation was not requested.

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 7b0d769e-fb8b-4a7e-985d-e7f4bb3c7356
Copilot AI review requested due to automatic review settings August 6, 2026 16:06

@missymessa missymessa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM shipit

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

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

Suppressed comments (6)

src/Microsoft.DotNet.Helix/AzureDevOpsTestPublisher/AzureDevOpsResultPublisher.cs:411

  • The previous implementation treated the parameter as a retry count (which results in retryCount + 1 total attempts). This new version treats it as a total attempt count (MaxAttempts = attemptCount), which reduces the number of tries for existing call sites (e.g., a prior DefaultRetryCount = 10 would have produced 11 total attempts). Consider either (a) adjusting call sites/constants to preserve the previous total attempts, or (b) renaming/documenting the parameter/constant to make the semantic change explicit. Also consider guarding against attemptCount <= 0 (which currently results in zero requests and an unexpected exception).
    private async Task<HttpResponseMessage> SendWithRetryAsync(
        HttpMethod method,
        string relativePath,
        object? payload,
        int attemptCount,
        CancellationToken cancellationToken)
    {
        string? body = payload is null ? null : JsonSerializer.Serialize(payload, s_serializerOptions);
        if (!string.IsNullOrEmpty(body))
        {
            s_lastSendContent = body;
        }

        HttpResponseMessage? successfulResponse = null;
        Exception? lastException = null;
        var retryHandler = new ExponentialRetry
        {
            MaxAttempts = attemptCount,
            DelayBase = 3,
            DelayConstant = 0,
            MinRandomFactor = 1,
            MaxRandomFactor = 1,
            MaximumDelay = s_maximumRetryDelay,
        };

src/Microsoft.DotNet.Helix/AzureDevOpsTestPublisher/Model/AzureDevOpsReportingParameters.cs:11

  • AzureDevOpsReportingParameters is public and this change removes the RetryWrites parameter/property entirely, which is a breaking API change for any external consumers. If this package is consumed outside this repo, consider keeping RetryWrites as an obsolete parameter (ignored) for backwards compatibility, or introducing a new type/overload and handling the transition via versioning/release notes.
public sealed record AzureDevOpsReportingParameters(
    Uri CollectionUri,
    string TeamProject,
    string TestRunId,
    string? AccessToken = null,
    bool UseFullyQualifiedTestName = false);

src/Microsoft.DotNet.Helix/JobMonitor/Services/HelixService.cs:410

  • This helper retries all exceptions (other than when the provided token is canceled). That can unnecessarily amplify load and latency for non-transient failures (e.g., auth/permission errors, 4xx-equivalent service exceptions, bad arguments) by retrying them multiple times. Consider narrowing the catch filter to known transient exceptions (or a shared transient detector), and let non-transient exceptions fail fast.
        private static async Task<T> RetryAsync<T>(Func<Task<T>> action, CancellationToken cancellationToken)
        {
            Exception last = null;
            T result = default;
            var retryHandler = new ExponentialRetry
            {
                MaxAttempts = 5,
                DelayBase = 2,
                DelayConstant = 0,
                MinRandomFactor = 1,
                MaxRandomFactor = 1,
            };

            bool succeeded = await retryHandler.RunAsync(
                async _ =>
                {
                    try
                    {
                        result = await action();
                        return RetryResult.Success;
                    }
                    catch (Exception ex) when (!cancellationToken.IsCancellationRequested)
                    {
                        last = ex;
                        return RetryResult.Retry();
                    }
                },
                cancellationToken);

src/Microsoft.DotNet.Helix/JobMonitor/TestResultUploadQueue.cs:197

  • If nullable reference types are enabled in this project, Exception lastException = null; will produce warnings because Exception is non-nullable. Prefer Exception? lastException = null; and keep the later throw lastException ?? ... as-is.
                T result = default;
                Exception lastException = null;

src/Microsoft.DotNet.Helix/JobMonitor/Services/AzureDevOpsService.cs:523

  • Two issues here: (1) retryTransientFailures suggests only transient failures should be retried, but the catch retries any exception when the token isn't canceled—consider filtering to transient exceptions or specific AzDO failure types. (2) If NRT is enabled, string result = null; and Exception lastException = null; should be nullable (string?, Exception?) to avoid warnings.
            string result = null;
            Exception lastException = null;
            var retryHandler = new ExponentialRetry
            {
                MaxAttempts = 5,
                DelayBase = 2,
                DelayConstant = 0,
                MinRandomFactor = 1,
                MaxRandomFactor = 1,
            };

            bool succeeded = await retryHandler.RunAsync(
                async _ =>
                {
                    try
                    {
                        result = await SendOnceAsync();
                        return RetryResult.Success;
                    }
                    catch (Exception ex) when (!cancellationToken.IsCancellationRequested)
                    {
                        lastException = ex;
                        return RetryResult.Retry();
                    }
                },
                cancellationToken);

src/Common/Microsoft.Arcade.Common/ExponentialRetry.cs:78

  • The new RetryAfter behavior is a key change, but the added tests don't appear to assert that a provided RetryAfter is honored (including the documented case where it exceeds MaximumDelay). Consider adding a unit test that returns RetryResult.Retry(retryAfter: ...) and verifies the duration passed to Task.Delay (e.g., via an injectable delay strategy or time abstraction) to lock in this contract.
                TimeSpan delay = result.RetryAfter is TimeSpan retryAfter
                    ? TimeSpan.FromTicks(Math.Max(exponentialDelay.Ticks, retryAfter.Ticks))
                    : exponentialDelay;

@mmitche
mmitche enabled auto-merge (squash) August 6, 2026 17:24
@mmitche
mmitche merged commit cddc57f into dotnet:main Aug 6, 2026
9 of 12 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-rc1 milestone Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants