Repository navigation
Add per-mock rate to MockResponsePlugin - #2027
Open
waldekmastykarz wants to merge 1 commit into
Open
waldekmastykarz wants to merge 1 commit into
waldekmastykarz wants to merge 1 commit into
Conversation
Adds an optional rate (0-100, default 100) to mock entries. When the roll fails, the mock is skipped and the request falls through to the next matching mock, plugin, or the real API. Out-of-range rates log a warning and are ignored. Bumps version to 4.1.0 and adds rate to the v4.1.0 mocks file schema. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Schema validation rejects an entire mocks file for out-of-range rates, preventing the warning fallback and unrelated valid mocks from loading; the schema needs adjustment and a schema-enabled loading test.
1 open issue
What changed in this PR
Adds per-mock response probabilities to Dev Proxy, addressing the failure-rate request in #103 while preserving always-apply behavior when rate is omitted.
Changes:
- Adds rate-based mock selection after
nthmatching, with fallthrough and warnings for out-of-range values. - Adds integration coverage for default, boundary, invalid, partial-rate, and fallthrough behavior.
- Updates version metadata to 4.1.0, adds versioned schemas, and refreshes bundled schema references.
| File | Description |
|---|---|
| scripts/version.ps1 | Updates beta version. |
| scripts/local-setup.ps1 | Updates local setup version. |
| scripts/Dockerfile_local | Updates local image version. |
| schemas/v4.1.0/websocketmockresponseplugin.schema.json | Adds versioned WebSocket configuration schema. |
| schemas/v4.1.0/websocketmockresponseplugin.mocksfile.schema.json | Adds versioned WebSocket mocks schema. |
| schemas/v4.1.0/typespecgeneratorplugin.schema.json | Adds versioned TypeSpec configuration schema. |
| schemas/v4.1.0/rewriteplugin.schema.json | Adds versioned rewrite configuration schema. |
| schemas/v4.1.0/rewriteplugin.rewritesfile.schema.json | Adds versioned rewrite rules schema. |
| schemas/v4.1.0/rc.schema.json | Adds versioned main configuration schema. |
| schemas/v4.1.0/ratelimitingplugin.schema.json | Adds versioned rate-limiting configuration schema. |
| schemas/v4.1.0/ratelimitingplugin.customresponsefile.schema.json | Adds versioned throttling response schema. |
| schemas/v4.1.0/openapispecgeneratorplugin.schema.json | Adds versioned OpenAPI generator schema. |
| schemas/v4.1.0/openaitelemetryplugin.schema.json | Adds versioned telemetry configuration schema. |
| schemas/v4.1.0/openaitelemetryplugin.pricesfile.schema.json | Adds versioned model pricing schema. |
| schemas/v4.1.0/mockstdioresponseplugin.schema.json | Adds versioned stdio configuration schema. |
| schemas/v4.1.0/mockstdioresponseplugin.mocksfile.schema.json | Adds versioned stdio mocks schema. |
| schemas/v4.1.0/mockresponseplugin.schema.json | Adds versioned HTTP mock configuration schema. |
| schemas/v4.1.0/mockresponseplugin.mocksfile.schema.json | Defines optional per-mock rate. |
| schemas/v4.1.0/mockrequestplugin.schema.json | Adds versioned mock request configuration schema. |
| schemas/v4.1.0/mockrequestplugin.mockfile.schema.json | Adds versioned mock request schema. |
| schemas/v4.1.0/minimalpermissionsplugin.schema.json | Adds versioned permissions configuration schema. |
| schemas/v4.1.0/minimalpermissionsguidanceplugin.schema.json | Adds versioned permissions guidance schema. |
| schemas/v4.1.0/minimalcsompermissionsplugin.schema.json | Adds versioned CSOM permissions configuration schema. |
| schemas/v4.1.0/minimalcsompermissions.types.schema.json | Adds versioned CSOM types schema. |
| schemas/v4.1.0/latencyplugin.schema.json | Adds versioned latency configuration schema. |
| schemas/v4.1.0/languagemodelratelimitingplugin.schema.json | Adds versioned token rate-limiting schema. |
| schemas/v4.1.0/languagemodelratelimitingplugin.customresponsefile.schema.json | Adds versioned token-limit response schema. |
| schemas/v4.1.0/languagemodelfailureplugin.schema.json | Adds versioned language-model failure schema. |
| schemas/v4.1.0/httpfilegeneratorplugin.schema.json | Adds versioned HTTP file generator schema. |
| schemas/v4.1.0/hargeneratorplugin.schema.json | Adds versioned HAR generator schema. |
| schemas/v4.1.0/graphrandomerrorplugin.schema.json | Adds versioned Graph error configuration schema. |
| schemas/v4.1.0/graphminimalpermissionsplugin.schema.json | Adds versioned Graph permissions schema. |
| schemas/v4.1.0/graphminimalpermissionsguidanceplugin.schema.json | Adds versioned Graph permissions guidance schema. |
| schemas/v4.1.0/genericrandomerrorplugin.schema.json | Adds versioned random-error configuration schema. |
| schemas/v4.1.0/genericrandomerrorplugin.errorsfile.schema.json | Adds versioned error responses schema. |
| schemas/v4.1.0/executionsummaryplugin.schema.json | Adds versioned execution summary schema. |
| schemas/v4.1.0/devtoolsplugin.schema.json | Adds versioned DevTools configuration schema. |
| schemas/v4.1.0/crudapiplugin.schema.json | Adds versioned CRUD configuration schema. |
| schemas/v4.1.0/crudapiplugin.apifile.schema.json | Adds versioned CRUD API definition schema. |
| schemas/v4.1.0/cachingguidanceplugin.schema.json | Adds versioned caching guidance schema. |
| schemas/v4.1.0/authplugin.schema.json | Adds versioned authentication configuration schema. |
| schemas/v4.1.0/apicenterproductionversionplugin.schema.json | Adds versioned API Center production-version schema. |
| schemas/v4.1.0/apicenteronboardingplugin.schema.json | Adds versioned API Center onboarding schema. |
| schemas/v4.1.0/apicenterminimalpermissionsplugin.schema.json | Adds versioned API Center permissions schema. |
| install.iss | Updates stable installer metadata. |
| install-beta.iss | Updates beta installer metadata. |
| Dockerfile_beta | Updates beta image version argument. |
| Dockerfile | Updates stable image version argument. |
| DevProxy/packages.lock.json | Updates the abstractions project dependency version. |
| DevProxy/devproxyrc.yaml | Updates editor schema annotations. |
| DevProxy/devproxyrc.json | Updates default configuration schema references. |
| DevProxy/DevProxy.csproj | Updates application version. |
| DevProxy/devproxy-errors.yaml | Updates editor schema annotation. |
| DevProxy/devproxy-errors.json | Updates error responses schema reference. |
| DevProxy/config/spo-csom-types.json | Updates CSOM types schema reference. |
| DevProxy/config/microsoft-graph.json | Updates Graph configuration schema references. |
| DevProxy/config/microsoft-graph-rate-limiting.json | Updates rate-limiting configuration schema reference. |
| DevProxy/config/m365.json | Updates M365 configuration schema references. |
| DevProxy/config/m365-mocks.json | Updates M365 mocks schema reference. |
| DevProxy/config-templates/devproxyrc.yaml | Updates template editor schema annotation. |
| DevProxy/config-templates/devproxyrc.json | Updates template schema reference. |
| DevProxy.Proxy.Kestrel/DevProxy.Proxy.Kestrel.csproj | Updates proxy engine version. |
| DevProxy.Plugins/Mocking/WebSocketMockResponsePlugin.cs | Updates default WebSocket mocks schema URL. |
| DevProxy.Plugins/Mocking/MockStdioResponsePlugin.cs | Updates default stdio mocks schema URL. |
| DevProxy.Plugins/Mocking/MockResponsesLoader.cs | Warns about out-of-range mock rates. |
| DevProxy.Plugins/Mocking/MockResponsePlugin.cs | Adds probabilistic selection and updates schema URL. |
| DevProxy.Plugins/DevProxy.Plugins.csproj | Updates plugins version. |
| DevProxy.Integration.Tests/ManipulationAndMockingIntegrationTests.cs | Adds rate and fallthrough integration tests. |
| DevProxy.Abstractions/Models/MockResponse.cs | Adds nullable Rate property. |
| DevProxy.Abstractions/DevProxy.Abstractions.csproj | Updates abstractions version. |
Review effort: Balanced
This was referenced Oct 31, 2026
This branch has not been deployed
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.

Closes #103
Adds an optional
rateproperty (integer 0-100, default 100) to mock entries in the mocks file.nthcheck), Dev Proxy rolls 1-100. If the roll is greater thanrate, the mock is skipped and the request falls through to the next matching mock, the next plugin, or the real API.MockResponsePlugin(and plugins that inherit its matching) honorsrate.ratetoschemas/v4.1.0/mockresponseplugin.mocksfile.schema.json.rate,rateof 0, 50 and 100, invalid values, fallthrough to the next mock, andnthcombined withrate.