Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions tools/code/common/Http.cs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ private static bool ShouldRetryInner(HttpMessage message, Exception? exception)
(message, exception) switch
{
({ Response.Status: 422 or 409 }, _) when HasManagementApiRequestFailedError(message.Response) => true,
({ Response.Status: 409 }, _) when HasConflictError(message.Response) && HasOperationOnTheApiIsInProgressMessage(message.Response) => true,
({ Response.Status: 409 }, _) when HasConflictOrPessimisticConcurrencyConflictError(message.Response) && HasOperationOnTheApiIsInProgressMessage(message.Response) => true,
({ Response.Status: 412 }, _) => true,
({ Response.Status: 429 }, _) => true,
_ => false
Expand All @@ -419,9 +419,12 @@ private static bool HasManagementApiRequestFailedError(Response response) =>
.Where(code => code.Equals("ManagementApiRequestFailed", StringComparison.OrdinalIgnoreCase))
.IsSome;

private static bool HasConflictError(Response response) =>
private static bool HasConflictOrPessimisticConcurrencyConflictError(Response response) =>
TryGetErrorCode(response)
.Where(code => code.Equals("Conflict", StringComparison.OrdinalIgnoreCase))
.Where(code =>
code.Equals("Conflict", StringComparison.OrdinalIgnoreCase) ||
code.Equals("PessimisticConcurrencyConflict", StringComparison.OrdinalIgnoreCase)
)
.IsSome;

private static bool HasOperationOnTheApiIsInProgressMessage(Response response) =>
Expand Down