Skip to content

Default Content-Type to application/json for generic error and custom rate-limit responses - #1986

Open
waldekmastykarz wants to merge 1 commit into
dotnet:mainfrom
waldekmastykarz:fix-1971-missing-content-type
Open

waldekmastykarz wants to merge 1 commit into
dotnet:mainfrom
waldekmastykarz:fix-1971-missing-content-type

Conversation

@waldekmastykarz

Copy link
Copy Markdown
Collaborator

Closes #1971

GenericRandomErrorPlugin responses and RateLimitingPlugin custom responses now get Content-Type: application/json when they have a body and no Content-Type header is configured. This mirrors how MockResponsePlugin defaults the content type. An explicitly configured Content-Type is preserved.

Tests

Added integration tests in BehaviorPluginsIntegrationTests:

  • generic error with a JSON body and no Content-Type → application/json
  • generic error with an explicit Content-Type → kept as-is, not duplicated
  • rate-limit custom response with a body → application/json

… rate-limit responses

GenericRandomErrorPlugin and RateLimitingPlugin (custom response) now add
Content-Type: application/json when the response has a body and no
Content-Type header is configured, matching MockResponsePlugin.

Closes dotnet#1971

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: b01cdbfd-df85-41d9-925d-3fe22389de95
@waldekmastykarz
waldekmastykarz requested a review from a team as a code owner October 21, 2026 13:55
Copilot AI balanced review requested due to automatic review settings October 21, 2026 13:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The narrow changes preserve configured headers and have focused integration coverage, with no blocking issues identified; tests were not executed.

No open issues 🎉

What changed in this PR

Aligns generated error and custom rate-limit responses with mock-response defaults, addressing #1971.

Changes:

  • Defaults Content-Type to application/json for non-null bodies.
  • Preserves explicitly configured content types.
  • Adds integration coverage for defaults and header preservation.
File Description
DevProxy.Plugins/​Behavior/​RateLimitingPlugin.cs Defaults content type for custom responses.
DevProxy.Plugins/​Behavior/​GenericRandomErrorPlugin.cs Defaults content type for error responses.
DevProxy.Integration.Tests/​BehaviorPluginsIntegrationTests.cs Tests defaults and explicit-header preservation.

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused changes preserve configured headers and have relevant integration coverage; tests were not executed.

No open issues 🎉

Review effort: Balanced

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generated error and custom rate-limit responses have no Content-Type

2 participants