Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GetTradeOffer exception #3164

Merged
merged 1 commit into from
Mar 19, 2024
Merged

Fix GetTradeOffer exception #3164

merged 1 commit into from
Mar 19, 2024

Conversation

Citrinate
Copy link
Contributor

@Citrinate Citrinate commented Mar 19, 2024

Checklist

  • I read and understood the Contributing Guidelines.
  • This is not a duplicate of an existing merge request.
  • I believe this falls into the scope of the project and should be part of the built-in functionality.
  • My code follows the code style of this project.
  • I have added tests to cover my changes, wherever they are necessary.
  • All new and existing tests pass.

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 JustArchi added 🐛 Bug Issues marked with this label indicate unintended program behaviour that needs correction. ✨ Enhancement Issues marked with this label indicate further enhancements to the program, such as new features. ✔️ Confirmed Issues marked with this label were acknowledged and confirmed by the developers. labels Mar 19, 2024
@JustArchi
Copy link
Member

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

@JustArchi JustArchi merged commit b9ab3d6 into JustArchiNET:main Mar 19, 2024
21 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🐛 Bug Issues marked with this label indicate unintended program behaviour that needs correction. ✔️ Confirmed Issues marked with this label were acknowledged and confirmed by the developers. ✨ Enhancement Issues marked with this label indicate further enhancements to the program, such as new features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants