question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

System.ArgumentException: An item with the same key has already been added. Key: xyz

See original GitHub issue

I’ve created this sample repo to demonstrate the exception outlined in the subject line. The details of the issue have been described in the README.md file of that repo.

Would you please share a solution because renaming public MyRequest Request { get; set; } in both MySubmittedData and YourSubmittedData classes is not feasible? Doing so will lead to other complexities and break the code’s architecture (outside of this repo).

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
mark-comeaucommented, May 5, 2021

Seems like what is needed is a configuration setting and functionality similar to CustomSchemaIds as implemented here: https://github.com/domaindrivendev/Swashbuckle.AspNetCore#customize-schema-ids.

0reactions
tijmenamsingcommented, May 19, 2022

I have the same issue with nested generic types. Downgrading to 1.0.0 doesn’t fix it for me either.

Having these combined fails for me with the error message: An item with the same key has already been added. Key: Response_list

  • [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: MediaTypeNames.Application.Json, bodyType: typeof(Response<List<Version>>))]
  • [OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: MediaTypeNames.Application.Json, bodyType: typeof(Response<List<Endpoint>>))]

I worked around the issue by changing the body types to Response<Version[]> and Response<Endpoint[]>

Read more comments on GitHub >

github_iconTop Results From Across the Web

An item with the same key has already been added
An item with the same key has already been added. And the exception details: [ArgumentException: An item with the same key has already...
Read more >
An Item With the Same Key Has Already Been Added
An item with the same key has already been added error happens when the model has the same property twice. Click here to...
Read more >
An item with the same key has already been added c# MVC
So start by looking at the error message: An item with the same key has already been added.
Read more >
Error "An item with the same key has already been added"
This scenario typically occurs if an operating system image is being used to deploy cluster nodes and that image was not correctly prepared...
Read more >
An item with the same key has already been added Error
The error reads: "An item with the same key has already been added." It does not matter if I include the database name...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found