Set-MgRequestContext: expose RetryUnprocessedMutationsOnly so POST and PATCH aren't resent after a 504

Offen
#3,917 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 7 Tagen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
56/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
csharp, powershell

Rechercherichtung

Start by tracing IRequestContext, RequestContext, Set-MgRequestContext, and the RetryHandlerOption construction in GraphHttpClientFactory; check the related Get-MgRequestContext documentation and existing tests. Confirm the target SDK versions and that the resolved Kiota HTTP client library supports the option. Done when the setting can be configured through the request context, defaults to false, and the cmdlet and documentation reflect it.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Is your feature request related to a problem? Please describe the problem.

The Graph PowerShell SDK retries a POST after a 504 Gateway Timeout, which can repeat its side effect. With sendMail, one Invoke-MgGraphRequest call can deliver the same email up to four times while the caller sees one error. The reproduction and investigation are in microsoft/kiota-dotnet#851.

Kiota has since added an opt-in setting for this, RetryHandlerOption.RetryUnprocessedMutationsOnly (microsoft/kiota-dotnet#864, merged and expected in kiota-dotnet 2.2.0). When it's on, POST and PATCH are retried only after a 429 or 503, and other responses, including a 504, go back to the caller. It defaults to off.

PowerShell users can't turn it on yet, because Set-MgRequestContext only exposes MaxRetry, RetryDelay, RetriesTimeLimit and ClientTimeout. The only workaround today is Set-MgRequestContext -MaxRetry 0 around each send. That setting is process-wide, so while a send is in flight it also turns off retries for every other Graph request in the process, and two overlapping sends in different runspaces can undo each other's setting.

Describe the solution you'd like.

Expose the setting through the request context:

  • add bool RetryUnprocessedMutationsOnly to IRequestContext, defaulting to false in RequestContext
  • add a -RetryUnprocessedMutationsOnly switch to Set-MgRequestContext, following the existing BoundParameters pattern
  • pass it into the RetryHandlerOption that GraphHttpClientFactory already builds from the request context
  • update the Set-MgRequestContext and Get-MgRequestContext docs
Set-MgRequestContext -RetryUnprocessedMutationsOnly
Additional context?

This needs Microsoft.Kiota.Http.HttpClientLibrary 2.2.0 or later, which the Authentication module currently gets through Microsoft.Graph.Core.

Open questions:

  1. Should this target V2, V3 (#3874), or both?
  2. Is a direct reference to Kiota 2.2.0 acceptable, or should this wait for a Microsoft.Graph.Core release that requires it?

I'm happy to open the PR once 2.2.0 ships.

Vorherrschende Sprache
C#
Sterne
911
Forks
236
Ø Merge
9 T. 18 Std.
Gemergte PRs (30 T.)
33

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus microsoftgraph/msgraph-sdk-powershell

Alle Issues in microsoftgraph/msgraph-sdk-powershell

Ähnliche Issues

Weitere Issues zu C#

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.