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: limit

See original GitHub issue

Getting this error when trying to make a call to Client.Browse.GetCategoryPlaylists and passing a CategoriesPlaylistsRequest. The CategoriesPlaylistsRequest is

{
    Country = null,
    Limit = 1,
    Offset = null
}

Here’s the full stack trace:

System.ArgumentException: An item with the same key has already been added. Key: limit
   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 SpotifyAPI.Web.RequestParams.AddQueryParam(Dictionary`2 queryParams, PropertyInfo prop, QueryParamAttribute attribute) in D:\Documents\GitHub\SpotifyAPI-NET\SpotifyAPI.Web\Models\Request\RequestParams.cs:line 149
   at SpotifyAPI.Web.RequestParams.BuildQueryParams() in D:\Documents\GitHub\SpotifyAPI-NET\SpotifyAPI.Web\Models\Request\RequestParams.cs:line 76
   at SpotifyAPI.Web.BrowseClient.GetCategoryPlaylists(String categoryId, CategoriesPlaylistsRequest request) in D:\Documents\GitHub\SpotifyAPI-NET\SpotifyAPI.Web\Clients\BrowseClient.cs:line 51
   at MusicPlatform.Spotify.SpotifyPlatform.GetPlaylistsByGenre(Genre genre, PlaylistsGetRequest request) in C:\Users\54962\source\repos\smfields\Boogie\Boogie\MusicPlatform\Models\Implementations\Spotify\SpotifyPlatform.cs:line 141
   at MorseCode.ITask.TaskAwaiterWrapper`1.MorseCode.ITask.IAwaiter<TResult>.GetResult()
   at Groovy.Controllers.PlaylistController.GetPlaylistsByGenre(Platform platform, Genre genre, Nullable`1 limit, Nullable`1 offset) in C:\Users\54962\source\repos\smfields\Boogie\Boogie\Boogie\Controllers\PlaylistController.cs:line 129
   at lambda_method73(Closure , Object )
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
JohnnyCrazycommented, Mar 4, 2021

@fjmorel @smfields Just published 6.1.0, so feel free to switch to the nuget version!

1reaction
fjmorelcommented, Mar 4, 2021

Hey, I had a similar issue today with q, so I’m glad to hear a fix will be out soon.

System.ArgumentException: An item with the same key has already been added. Key: q
   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 SpotifyAPI.Web.RequestParams.AddQueryParam(Dictionary`2 queryParams, PropertyInfo prop, QueryParamAttribute attribute)
   at SpotifyAPI.Web.RequestParams.BuildQueryParams()
   at SpotifyAPI.Web.SearchClient.Item(SearchRequest request)
   at MusicMatching_NSB.Services.SpotifyService.SearchTracksByIsrc(String isrc, Int32 limit, Int32 offset, String market) in /src/Queues/MusicMatching_NSB/Services/SpotifyService.cs:line 140
Read more comments on GitHub >

github_iconTop Results From Across the Web

An item with the same key has already been added
Solution is to override the property or use another name. If you share your model, we would be able to elaborate more. Share....
Read more >
Error "An item with the same key has already been added"
Cause. This scenario typically occurs if an operating system image is being used to deploy cluster nodes and that image was not correctly ......
Read more >
ERROR An item with the same key has already been added
The "Item with the same key" refers to the fact that the a duplicate key is found when the code tries to read...
Read more >
An Item With the Same Key Has Already Been Added
An item with the same key has already been added dictionary error happens when your project includes a model with the same property...
Read more >
'An item with the same key has already been added' error after ...
An error with message 'An item with the same key has already been added' is shown in the error logs after submitting a...
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