Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions DevProxy.Abstractions/Models/GraphBatchRequestPayload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class GraphBatchRequestPayload
public class GraphBatchRequestPayloadRequest
{
public object? Body { get; set; }
public IEnumerable<string>? DependsOn { get; set; }
#pragma warning disable CA2227
Comment thread
waldekmastykarz marked this conversation as resolved.
public Dictionary<string, string>? Headers { get; set; } = [];
#pragma warning restore CA2227
Expand Down
10 changes: 7 additions & 3 deletions DevProxy.Plugins/Behavior/GraphRandomErrorPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,12 @@ private void FailBatch(ProxyRequestArgs e)
try
{
// pick a random error response for the current request method
// if the request has dependencies, use FailedDependency status code
// https://learn.microsoft.com/en-us/graph/json-batching?tabs=http#sequencing-requests-with-the-dependson-property
var methodStatusCodes = _methodStatusCode[request.Method];
var errorStatus = methodStatusCodes[_random.Next(0, methodStatusCodes.Length)];
var errorStatus = request.DependsOn is not null && request.DependsOn.Any() ?
HttpStatusCode.FailedDependency :
methodStatusCodes[_random.Next(0, methodStatusCodes.Length)];

var response = new GraphBatchResponsePayloadResponse
{
Expand Down Expand Up @@ -315,8 +319,8 @@ private void UpdateProxyResponse(ProxyRequestArgs e, HttpStatusCode errorStatus)

private void UpdateProxyBatchResponse(ProxyRequestArgs ev, GraphBatchResponsePayload response)
{
// failed batch uses a fixed 424 error status code
var errorStatus = HttpStatusCode.FailedDependency;
// failed batch uses 200 OK status code
var errorStatus = HttpStatusCode.OK;

var session = ev.Session;
var requestId = Guid.NewGuid().ToString();
Expand Down