Skip to content

Validate LatencyPlugin minMs <= maxMs at startup - #1982

Merged
waldekmastykarz merged 1 commit into
dotnet:mainfrom
waldekmastykarz:fix-1962-latency-min-max
Oct 26, 2026
Merged

waldekmastykarz merged 1 commit into
dotnet:mainfrom
waldekmastykarz:fix-1962-latency-min-max

Conversation

@waldekmastykarz

Copy link
Copy Markdown
Collaborator

Closes #1962

Problem

When minMs > maxMs, LatencyPlugin threw ArgumentOutOfRangeException from Random.NextInt64 on every request.

Fix

LatencyPlugin now validates its configuration in InitializeAsync. When minMs > maxMs, it disables itself and throws InvalidOperationException, so Dev Proxy fails at startup with a clear message:

LatencyPlugin: minMs (500) must be less than or equal to maxMs (100).

This follows the existing pattern in MinimalPermissionsPlugin. minMs == maxMs stays valid.

Tests

  • Latency_InitializeFailsWhenMinMsGreaterThanMaxMs
  • Latency_InitializeSucceedsWhenMinMsEqualsMaxMs

I also checked it by hand: running the proxy with minMs: 500, maxMs: 100 exits with code 1 and prints the message above.

LatencyPlugin now checks its configuration in InitializeAsync and fails
startup with a clear error when minMs is greater than maxMs, instead of
throwing ArgumentOutOfRangeException from Random.NextInt64 on every
request.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d9a7d55f-79d1-4bd6-b965-baff95d04e36
@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 focused validation and boundary-case tests address the reported issue without identified blockers.

No open issues 🎉

What changed in this PR

Moves invalid latency-range detection to startup, preventing repeated request-time exceptions and addressing #1962.

Changes:

  • Disables LatencyPlugin and throws a clear error when minMs > maxMs.
  • Adds tests for invalid ranges and valid equal bounds.
File Description
DevProxy.Plugins/​Behavior/​LatencyPlugin.cs Validates latency bounds during initialization.
DevProxy.Integration.Tests/​BehaviorPluginsIntegrationTests.cs Tests rejection of reversed bounds and acceptance of equal bounds.

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 validation preserves equal bounds and has regression coverage, with no blocking issues identified in static review.

No open issues 🎉

Review effort: Balanced

@waldekmastykarz
waldekmastykarz merged commit 64adc94 into dotnet:main Oct 26, 2026
4 checks passed
@waldekmastykarz
waldekmastykarz deleted the fix-1962-latency-min-max branch October 26, 2026 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants