Skip to content

Conversation

@waldekmastykarz
Copy link
Collaborator

Description

Fixes #1503

When a mock error response doesn't specify a method, the GenericRandomErrorPlugin now matches all HTTP methods instead of only GET requests.

Changes

  1. Made the Method property in GenericErrorResponseRequest nullable
  2. Updated the matching logic to skip method comparison when method is not specified

Before

{
  "request": {
    "url": "https://api.example.com/*"
  },
  "responses": [...]
}

This would only match GET requests because Method defaulted to "GET".

After

The same config now matches all HTTP methods (GET, POST, PUT, DELETE, etc.).

To match a specific method, explicitly set it:

{
  "request": {
    "url": "https://api.example.com/*",
    "method": "POST"
  },
  "responses": [...]
}

…ified

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 dotnet#1503
@waldekmastykarz waldekmastykarz added the pr-bugfix Fixes a bug label Jan 18, 2026
@waldekmastykarz waldekmastykarz requested a review from a team as a code owner January 18, 2026 17:23
Copilot AI review requested due to automatic review settings January 18, 2026 17:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug in the GenericRandomErrorPlugin where error responses without a specified HTTP method would only match GET requests instead of matching all HTTP methods. The fix makes the Method property nullable and updates the matching logic to skip method comparison when the method is not specified.

Changes:

  • Made the Method property nullable in GenericErrorResponseRequest to distinguish between "no method specified" and "specific method specified"
  • Updated the request matching logic to only check method equality when a method is explicitly configured

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
DevProxy.Plugins/Models/GenericErrorResponse.cs Changed Method property from non-nullable with default value "GET" to nullable without default
DevProxy.Plugins/Behavior/GenericRandomErrorPlugin.cs Added null check before comparing method to skip comparison when method is not specified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GenericRandomErrorPlugin doesn't match requests when method is not specified in mock

1 participant