Repository navigation
feat(http): add option to retry only unprocessed mutations - #225
Merged
Vincent Biret (baywet) merged 1 commit intoNov 13, 2026
Conversation
Add RetryHandlerOption's retry_unprocessed_mutations_only keyword. It defaults to false, which keeps the current behavior. When it is true, POST and PATCH requests are retried only after a 429 or 503 response, which indicate the server did not process the request, even when a custom should_retry accepts other responses. A 504 is returned to the caller, because the server may already have applied the request and a retry could apply it twice. Other methods are unaffected.
Jackson Smith (jackson-asmith)
requested a review
from a team
as a code owner
November 13, 2026 18:05
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block approval of the opt-in retry-protection change.
No open issues 🎉
What changed in this PR
Adds opt-in retry protection to Kiota Ruby’s HTTP middleware to reduce duplicate POST/PATCH side effects after ambiguous failures, addressing #224 while preserving existing behavior by default.
Changes:
- Adds and documents
retry_unprocessed_mutations_only, defaulting tofalse. - When enabled, restricts POST/PATCH retries to 429 and 503 responses while retaining existing retry checks.
- Adds regression coverage for defaults, custom policies, per-request options, repeated attempts, and redirects.
| File | Description |
|---|---|
components/http/spec/microsoft_kiota_faraday/middleware/retry_unprocessed_mutations_spec.rb |
Tests retry safety, compatibility, configuration, and redirect behavior. |
components/http/lib/microsoft_kiota_faraday/middleware/retry_handler.rb |
Applies method-specific retry restrictions on every attempt. |
components/http/lib/microsoft_kiota_faraday/middleware/retry_handler_option.rb |
Exposes the option and documents its default, risks, and service assumptions. |
Review effort: Balanced
Vincent Biret (baywet)
approved these changes
Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #224
This ports microsoft/kiota-dotnet#864 to Ruby. The other ports are microsoft/kiota-http-go#312, microsoft/kiota-python#897, microsoft/kiota-java#2251, microsoft/kiota-typescript#2230, microsoft/kiota-php#143 and microsoft/kiota-dart#179.
Problem
RetryHandler retries 429, 503 and 504 responses whatever the HTTP method. For POST and PATCH, a retry after a 504 can apply the request twice. A 504 means a gateway stopped waiting, not that the server did nothing, so the first attempt may already have succeeded. With Microsoft Graph's sendMail, this sends the same email twice.
A caller can avoid this today with a custom should_retry that checks response.env.method. Most callers, including users of the generated SDKs, never set should_retry, though, so they keep the retries that can send twice. A built-in option makes the safe behavior a single setting.
Change
This adds a retry_unprocessed_mutations_only keyword to RetryHandlerOption, matching the .NET option.
KiotaClientFactory adds RedirectHandler before RetryHandler, so the redirect handler wraps the retry handler and the retry handler only sees the request for the current redirect hop. Each retry resends that request, so its method is always the one being resent.
Tests
The new retry_unprocessed_mutations_spec.rb has 18 examples, using Faraday's test adapter with the real RedirectHandler and RetryHandler, covering:
With the new check removed, the 6 examples for the new behavior fail and the other 12 pass. Locally on Ruby 4.0, bundle exec rake for the http component (145 examples) and bundle exec rubocop from the repo root pass.