Skip to content

Conversation

LockTar
Copy link
Contributor

@LockTar LockTar commented Sep 18, 2025

The 422 and 409 errors are retried in combination with the ManagementApiRequestFailed error code as discussed in issue #497.
In our case, the publisher is failing randomly on an API with a response that is not handled in the retry policy.

Sample response:
Content: {"error":{"code":"Conflict","message":"Operation on the API is in progress","details":null}}.

This pull request improves the retry logic for HTTP requests in tools/code/common/Http.cs, specifically for handling certain API conflict scenarios. The main change is to add more granular checks for when a retry should occur, particularly for 409 Conflict responses related to ongoing API operations.

Enhanced retry logic for HTTP requests:

  • Added a new condition to ShouldRetryInner to retry when a 409 Conflict response has both the "Conflict" error code and the "Operation on the API is in progress" message.

New helper methods for response inspection:

  • Implemented HasConflictError to check if the response error code is "Conflict".
  • Implemented HasOperationOnTheApiIsInProgressMessage to check if the response error message is "Operation on the API is in progress".
  • Added TryGetMessage to extract the error message from the response JSON.

These changes make the retry logic more robust and specific, reducing unnecessary retries and better handling API concurrency scenarios.

Ralph Jansen added 2 commits September 18, 2025 14:17
Enhanced the `CommonRetryPolicy` class to handle retries for
HTTP 409 Conflict responses when the error code matches
"Conflict".

- Added a new condition to the `ShouldRetry` method's `switch`
  statement to check for 409 status and use the `HasConflictError`
  method.
- Introduced the `HasConflictError` method to encapsulate logic
  for identifying "Conflict" error codes using `TryGetErrorCode`.
- Reused the existing `TryGetErrorCode` method to support the
  new `HasConflictError` logic.

These changes improve the robustness of the retry policy by
handling additional conflict scenarios.
Updated `CommonRetryPolicy` to refine retry conditions for HTTP 409 responses. Added `HasOperationOnTheApiIsInProgressMessage` to check for specific API state messages. Introduced `TryGetMessage` for extracting the "message" property from response content. These changes improve retry precision and robustness by ensuring retries occur only when appropriate.
@waelkdouh waelkdouh added the bug Something isn't working label Sep 18, 2025
Copy link
Contributor

@guythetechie guythetechie left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, looks good. Haven't seen this error myself, but it makes sense that it should be retried.

@LockTar
Copy link
Contributor Author

LockTar commented Sep 18, 2025

Thank you for the fast replies. We have a lot of issues with this 409 error so hopefully this will be released soon.

@waelkdouh waelkdouh merged commit bf11787 into Azure:main Sep 18, 2025
1 check passed
@waelkdouh
Copy link
Contributor

Thank for the PR. I will be releasing the changes shortly.

@LockTar LockTar deleted the f/fix-409-conflict-errorcode branch September 19, 2025 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants