Skip to content

Commit 1963b65

Browse files
Changes failed Graph batch response to 200 OK. Closes #1358 (#1359)
1 parent b3061ac commit 1963b65

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

DevProxy.Abstractions/Models/GraphBatchRequestPayload.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class GraphBatchRequestPayload
1212
public class GraphBatchRequestPayloadRequest
1313
{
1414
public object? Body { get; set; }
15+
public IEnumerable<string>? DependsOn { get; set; }
1516
#pragma warning disable CA2227
1617
public Dictionary<string, string>? Headers { get; set; } = [];
1718
#pragma warning restore CA2227

DevProxy.Plugins/Behavior/GraphRandomErrorPlugin.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,12 @@ private void FailBatch(ProxyRequestArgs e)
234234
try
235235
{
236236
// pick a random error response for the current request method
237+
// if the request has dependencies, use FailedDependency status code
238+
// https://learn.microsoft.com/en-us/graph/json-batching?tabs=http#sequencing-requests-with-the-dependson-property
237239
var methodStatusCodes = _methodStatusCode[request.Method];
238-
var errorStatus = methodStatusCodes[_random.Next(0, methodStatusCodes.Length)];
240+
var errorStatus = request.DependsOn is not null && request.DependsOn.Any() ?
241+
HttpStatusCode.FailedDependency :
242+
methodStatusCodes[_random.Next(0, methodStatusCodes.Length)];
239243

240244
var response = new GraphBatchResponsePayloadResponse
241245
{
@@ -315,8 +319,8 @@ private void UpdateProxyResponse(ProxyRequestArgs e, HttpStatusCode errorStatus)
315319

316320
private void UpdateProxyBatchResponse(ProxyRequestArgs ev, GraphBatchResponsePayload response)
317321
{
318-
// failed batch uses a fixed 424 error status code
319-
var errorStatus = HttpStatusCode.FailedDependency;
322+
// failed batch uses 200 OK status code
323+
var errorStatus = HttpStatusCode.OK;
320324

321325
var session = ev.Session;
322326
var requestId = Guid.NewGuid().ToString();

0 commit comments

Comments
 (0)