Skip to content

[BUG]: An item with the same key has already been added. Key: Set-Cookie #1169

Closed
@ThaDaVos

Description

@ThaDaVos

Description

When making API calls to the service of Viva Payments, I keep getting errors like below:

 fail    An error occurred in a plugin Exception Details: System.Exception: Exception thrown in user event
 ---> System.ArgumentException: An item with the same key has already been added. Key: Set-Cookie
   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.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector)
   at DevProxy.Plugins.Inspection.DevToolsPlugin.AfterResponseAsync(Object sender, ProxyResponseArgs e)
   at DevProxy.Abstractions.FuncExtensions.InternalInvokeAsync[T](AsyncEventHandler`1 callback, Object sender, T args, ExceptionHandler exceptionFunc)
   --- End of inner exception stack trace ---

I guess due to this, my DevInspector Responses are also empty - so I can't really work with it now...
The requests are made using Microsoft Kiota

I saw the bug was also in the MockGeneratorPlugin: #358

Expected behaviour

No error? Or at least the Responses to be populated in the DevInspector

Actual behaviour

Error and empty responses in the DevInspector

Steps to reproduce

I guess it's Viva Payments specific - but probably all endpoints which violate the RFC 6265
https://www.rfc-editor.org/rfc/rfc6265#section-4.1.1

Dev Proxy Version

0.27.0

Operating system (environment)

Windows

Shell

PowerShell

Configuration file

{
    "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v0.27.0/rc.schema.json",
    "plugins": [
        {
            "name": "DevToolsPlugin",
            "enabled": true,
            "pluginPath": "~appFolder/plugins/dev-proxy-plugins.dll",
            "configSection": "devTools"
        }
    ],
    "devTools": {
        "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v0.27.0/devtoolsplugin.schema.json",
        "preferredBrowser": "Edge"
    },
    "urlsToWatch": [
        "https://demo-api.vivapayments.com/*",
        "https://api.vivapayments.com/*",
        "https://demo-accounts.vivapayments.com/connect/token",
        "https://accounts.vivapayments.com/connect/token"
    ],
    "logLevel": "debug",
    "newVersionNotification": "stable",
    "showSkipMessages": true,
    "showTimestamps": true
}

Additional Info

No response

Activity

waldekmastykarz

waldekmastykarz commented on May 10, 2025

@waldekmastykarz
Collaborator

Thanks for letting us know of this and sorry for the trouble. We'll get this fixed asap.

waldekmastykarz

waldekmastykarz commented on May 10, 2025

@waldekmastykarz
Collaborator

We need to see what's the best way to fix it because the Chrome DevTools Protocol lists headers as key-value pairs.

ThaDaVos

ThaDaVos commented on May 10, 2025

@ThaDaVos
Author

I would say, only pass the first on through to the DevTools - and give warnings in the Dev Proxy console about the dups - that way, at least the responses show up and if one is missing headers, they can see it inside the DevProxy console - best would be when showing the warning to show the Key and Value - this way it isn't fully lost

added a commit that references this issue on May 10, 2025
0546383
waldekmastykarz

waldekmastykarz commented on May 10, 2025

@waldekmastykarz
Collaborator

Turns out the standard way to go about it to combine all headers into one and put all values in a comma-separated string. I've just opened a PR. We should be able to do a new beta release with the fix on Monday. Have a great weekend, and thanks again for bringing it up.

added a commit that references this issue on May 13, 2025
54ecda9
ThaDaVos

ThaDaVos commented on May 13, 2025

@ThaDaVos
Author

I don't see an update - will this be done in the next update? Or does one update the plugin separately?

waldekmastykarz

waldekmastykarz commented on May 14, 2025

@waldekmastykarz
Collaborator

We've released a new beta just yesterday and had to wait for a few hours until it gets published on winget. It should be available now and you should see v0.28.0-beta.1 Otherwise, you can grab it from here: https://github.com/dotnet/dev-proxy/releases/tag/v0.28.0-beta.1. Thanks for checking

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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @ThaDaVos@waldekmastykarz

    Issue actions

      [BUG]: An item with the same key has already been added. Key: `Set-Cookie` · Issue #1169 · dotnet/dev-proxy