From ff994a19d6f9d16cefbacd552691b4d70378c77d Mon Sep 17 00:00:00 2001 From: waldekmastykarz Date: Sun, 18 Jan 2026 18:22:59 +0100 Subject: [PATCH] fix(GenericRandomErrorPlugin): match all methods when method not specified When a mock error response doesn't specify a method, the plugin now matches all HTTP methods instead of only GET requests. Previously, the Method property defaulted to 'GET', causing non-GET requests to fail matching when no method was specified in the config. Fixes #1503 --- DevProxy.Plugins/Behavior/GenericRandomErrorPlugin.cs | 3 ++- DevProxy.Plugins/Models/GenericErrorResponse.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/DevProxy.Plugins/Behavior/GenericRandomErrorPlugin.cs b/DevProxy.Plugins/Behavior/GenericRandomErrorPlugin.cs index c0981b99..92ed9bc9 100644 --- a/DevProxy.Plugins/Behavior/GenericRandomErrorPlugin.cs +++ b/DevProxy.Plugins/Behavior/GenericRandomErrorPlugin.cs @@ -183,7 +183,8 @@ private ThrottlingInfo ShouldThrottle(Request request, string throttlingKey) return false; } - if (errorResponse.Request.Method != request.Method) + if (errorResponse.Request.Method is not null && + errorResponse.Request.Method != request.Method) { return false; } diff --git a/DevProxy.Plugins/Models/GenericErrorResponse.cs b/DevProxy.Plugins/Models/GenericErrorResponse.cs index 87b7199a..289b7820 100644 --- a/DevProxy.Plugins/Models/GenericErrorResponse.cs +++ b/DevProxy.Plugins/Models/GenericErrorResponse.cs @@ -13,7 +13,7 @@ public class GenericErrorResponse public class GenericErrorResponseRequest { public string? BodyFragment { get; set; } - public string Method { get; set; } = "GET"; + public string? Method { get; set; } public string Url { get; set; } = string.Empty; }