Skip to content

[BUG]: When using EntraMockResponsePlugin and MockResponsePlugin it crashes with ArgumentException #1690

@Sjoerdsjoerd

Description

@Sjoerdsjoerd

Description

When using both the EntraMockResponsePlugin and MockResponsePlugin. The dev-proxy will not start-up. Because mocks is included in both configs and it is added in a dictionary.

Expected behaviour

Mocking both responses and MS Entra responses. I do like separate files because then I can set the watcher on the MS login urls. Also it splits responsibilities.

Actual behaviour

Crashing with:

 Unhandled exception during proxy run. Stopping restart loop.
 System.ArgumentException: An item with the same key has already been added. Key: mocks
    at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
    at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
    at System.CommandLine.Parsing.StringExtensions.<ValidTokens>g__AddCommandTokens|7_0(Dictionary`2 tokens, Command cmd)
    at System.CommandLine.Parsing.StringExtensions.ValidTokens(Command command)
    at System.CommandLine.Parsing.StringExtensions.Tokenize(IReadOnlyList`1 args, Command rootCommand, ParserConfiguration configuration, Boolean inferRootCommand, List`1& tokens, List`1& errors)
    at System.CommandLine.Parsing.CommandLineParser.Parse(Command command, IReadOnlyList`1 arguments, String rawInput, ParserConfiguration configuration)
    at System.CommandLine.Parsing.CommandLineParser.Parse(Command command, IReadOnlyList`1 args, ParserConfiguration configuration)
    at System.CommandLine.Command.Parse(IReadOnlyList`1 args, ParserConfiguration configuration)
    at DevProxy.Commands.DevProxyCommand.InvokeAsync(String[] args, WebApplication app)
    at Program.<<Main>$>g__RunProxyAsync|0_6(String[] args, DevProxyConfigOptions options)
    at Program.<<Main>$>g__RunProxyAsync|0_6(String[] args, DevProxyConfigOptions options)
    at Program.<Main>$(String[] args)

Steps to reproduce

Just run with these config files.

Dev Proxy Version

3.0.0

Operating system (environment)

Windows

Shell

cmd

Configuration file

{
  "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v3.0.0/rc.schema.json",
  "plugins": [
    {
      "name": "EntraMockResponsePlugin",
      "enabled": true,
      "pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
      "configSection": "entraMocks"
    },
    {
      "name": "MockResponsePlugin",
      "enabled": true,
      "pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
      "configSection": "mocksPlugin"
    }
  ],
  "entraMocks": {
    "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v3.0.0/mockresponseplugin.schema.json",
    "mocksFile": "entra-mocks.json"
  },
  "mocksPlugin": {
    "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v3.0.0/mockresponseplugin.schema.json",
    "mocksFile": "mocks.json"
  }
}

entra-mocks.json:

{
  "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v3.0.0/mockresponseplugin.mocksfile.schema.json",
  "mocks": []
}

mocks.json:

{
  "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v3.0.0/mockresponseplugin.mocksfile.schema.json",
  "mocks": []
}

Additional Info

No response

Metadata

Metadata

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions