JustArchiNET / ArchiSteamFarm

C# application with primary purpose of farming Steam cards from multiple accounts simultaneously.
Apache License 2.0
10.92k stars 1.04k forks source link

Fix GetTradeOffer exception #3164

Closed Citrinate closed 4 months ago

Citrinate commented 4 months ago

Checklist

Changes

New functionality

None

Changed functionality

None

Removed functionality

None

Additional info

Fixes an exception I've been seeing in 6.0.1.3 and 6.0.1.4 when trading between bots. On seemingly random trades, the same item will appear multiple times in the trade description, producing this error and blocking the trades from being accepted by ASF:

2024-03-18 20:15:46|ArchiSteamFarm-3412129|FATAL|ASF|OnUnobservedTaskException() System.ArgumentException: An item with the same key has already been added. Key: (753, 2320557464, 0)
   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 ArchiSteamFarm.Steam.Integration.ArchiWebHandler.GetTradeOffers(Nullable`1 activeOnly, Nullable`1 receivedOffers, Nullable`1 sentOffers, Nullable`1 withDescriptions) in /ArchiSteamFarm/ArchiSteamFarm/Steam/Integration/ArchiWebHandler.cs:line 505
   at ArchiSteamFarm.Steam.Exchange.Trading.ParseActiveTrades() in /ArchiSteamFarm/ArchiSteamFarm/Steam/Exchange/Trading.cs:line 263
   at ArchiSteamFarm.Steam.Exchange.Trading.OnNewTrade() in /ArchiSteamFarm/ArchiSteamFarm/Steam/Exchange/Trading.cs:line 231

If you'd like to see the response from https://api.steampowered.com/IEconService/GetTradeOffers that produces this error I can provide it.

JustArchi commented 4 months ago

I'll rewrite it to be a bit more performing solution but thanks for raising my attention and providing a fix :trophy: