Repository navigation
Fix off-by-one in random error plugins' failure rate check - #1929
Merged
Merged
Conversation
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix random error plugins to correctly apply configured rate
Fix off-by-one in random error plugins' failure rate check
Oct 20, 2026
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
Static review identified no blocking issues; the corrections match the reported defect, though tests were not executed.
No open issues 🎉
What changed in this PR
Corrects random-error probabilities in both plugins, addressing #1926 so configured rates apply accurately on average.
Changes:
- Fixes the random sampling range and comparison.
- Adds a regression test confirming
rate: 99permits requests through. - Updates transitive dependency lock entries.
| File | Description |
|---|---|
| DevProxy/packages.lock.json | Updates application dependency lock entries. |
| DevProxy.Proxy.Kestrel/packages.lock.json | Updates proxy-engine dependency lock entries. |
| DevProxy.Plugins/Behavior/GraphRandomErrorPlugin.cs | Corrects Graph error probability. |
| DevProxy.Plugins/Behavior/GenericRandomErrorPlugin.cs | Corrects generic error probability. |
| DevProxy.Integration.Tests/BehaviorPluginsIntegrationTests.cs | Adds rate-99 regression coverage. |
Review effort: Balanced
waldekmastykarz
marked this pull request as ready for review
October 20, 2026 17:49
Collaborator
|
@copilot build is failing. Fix |
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Contributor
Author
Fixed in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GenericRandomErrorPluginandGraphRandomErrorPlugindon't apply the configuredrateexactly.Random.Next(1, 100)excludes 100, so it only returns 1–99. As a result,rate: 99fails every request, and every other rate fails slightly more often than configured (rate: 50fails about 50.5% of requests).Changes
Rate check (
GenericRandomErrorPlugin.ShouldFail,GraphRandomErrorPlugin.ShouldFail): changed the roll to 0–99 and the comparison to strict, sorate: Nfails N% of requests on average.rate: 0never fails andrate: 100always fails, same as before.Test (
BehaviorPluginsIntegrationTests.GenericRandomError_Rate99_SometimesPassesThrough): sends requests through the proxy withrate: 99until one reaches the origin, up to 2,000 attempts. It fails on the old code. The test is random, so it can fail even with the fix, but only with a probability of about 2×10⁻⁹. There is no matching test forGraphRandomErrorPlugin.