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

System.Collections.Generic.KeyNotFoundException: The given key #70

Open
enutn opened this issue May 9, 2024 · 1 comment
Open

System.Collections.Generic.KeyNotFoundException: The given key #70

enutn opened this issue May 9, 2024 · 1 comment
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@enutn
Copy link

enutn commented May 9, 2024

2024-05-09 14:43:18|ArchiSteamFarm-23364|INFO|ASF|CollectGames() [FreeGames] found potentially 22 free games on reddit 2024-05-09 14:43:18|ArchiSteamFarm-23364|FATAL|ASF|OnUnhandledException() System.Collections.Generic.KeyNotFoundException: The given key 'Terreus' was not present in the dictionary. at System.Collections.Generic.Dictionary2.get_Item(TKey)
at ASFFreeGames.Commands.FreeGamesCommand.<>c__DisplayClass14_0.b__2(String botName)
at System.Linq.Enumerable.SelectListPartitionIterator2.MoveNext() at ASFFreeGames.Commands.FreeGamesCommand.CollectGames(IEnumerable1 bots, ECollectGameRequestSource requestSource, CancellationToken cancellationToken)
at ASFFreeGames.Commands.FreeGamesCommand.HandleInternalCollectCommand(Bot bot, String[] args, CancellationToken cancellationToken)
at ASFFreeGames.Commands.FreeGamesCommand.Execute(Bot bot, String message, String[] args, UInt64 steamID, CancellationToken cancellationToken)
at ASFFreeGames.Commands.CommandDispatcher.Execute(Bot bot, String message, String[] args, UInt64 steamID, CancellationToken cancellationToken)
at Maxisoft.ASF.ASFFreeGamesPlugin.OnBotCommand(Bot bot, EAccess access, String message, String[] args, UInt64 steamID)
at Maxisoft.ASF.ASFFreeGamesPlugin.CollectGamesOnClock(Object source)
at System.Threading.Tasks.Task.<>c.b__128_1(Object state)
at System.Threading.QueueUserWorkItemCallback.<>c.<.cctor>b__6_0(QueueUserWorkItemCallback quwi)
at System.Threading.ExecutionContext.RunForThreadPoolUnsafe[TState](ExecutionContext, Action1, TState& ) at System.Threading.QueueUserWorkItemCallback.Execute() at System.Threading.ThreadPoolWorkQueue.Dispatch() at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart() at System.Threading.Thread.StartCallback() 2024-05-09 14:43:18|ArchiSteamFarm-23364|ERROR|ASF|Exit() Exiting with 1 error code! 2024-05-09 14:43:18|ArchiSteamFarm-23364|INFO|Microsoft.Hosting.Lifetime|Application is shutting down... Unhandled exception. System.Collections.Generic.KeyNotFoundException: The given key 'Terreus' was not present in the dictionary. at System.Collections.Generic.Dictionary2.get_Item(TKey)
at ASFFreeGames.Commands.FreeGamesCommand.<>c__DisplayClass14_0.b__2(String botName)
at System.Linq.Enumerable.SelectListPartitionIterator2.MoveNext() at ASFFreeGames.Commands.FreeGamesCommand.CollectGames(IEnumerable1 bots, ECollectGameRequestSource requestSource, CancellationToken cancellationToken)
at ASFFreeGames.Commands.FreeGamesCommand.HandleInternalCollectCommand(Bot bot, String[] args, CancellationToken cancellationToken)
at ASFFreeGames.Commands.FreeGamesCommand.Execute(Bot bot, String message, String[] args, UInt64 steamID, CancellationToken cancellationToken)
at ASFFreeGames.Commands.CommandDispatcher.Execute(Bot bot, String message, String[] args, UInt64 steamID, CancellationToken cancellationToken)
at Maxisoft.ASF.ASFFreeGamesPlugin.OnBotCommand(Bot bot, EAccess access, String message, String[] args, UInt64 steamID)
at Maxisoft.ASF.ASFFreeGamesPlugin.CollectGamesOnClock(Object source)
at System.Threading.Tasks.Task.<>c.b__128_1(Object state)
at System.Threading.QueueUserWorkItemCallback.<>c.<.cctor>b__6_0(QueueUserWorkItemCallback quwi)
at System.Threading.ExecutionContext.RunForThreadPoolUnsafe[TState](ExecutionContext, Action1, TState& ) at System.Threading.QueueUserWorkItemCallback.Execute() at System.Threading.ThreadPoolWorkQueue.Dispatch() at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart() at System.Threading.Thread.StartCallback() zsh: abort /Users/********/*******/ASF-osx-x64/ArchiSteamFarm

Desktop:

  • OS: mcOS Sonoma
maxisoft added a commit that referenced this issue May 11, 2024
This commit resolves the `KeyNotFoundException` encountered during the scheduled free game collection process. The issue was caused by an attempt to access a non-existent key in the bot dictionary, as reported in issue #70.

Changes include:
- Added a check in `ASFFreeGamesPlugin.cs` to ensure there are viable bots before proceeding with the free game collection command.
- Modified `FreeGamesCommand.cs` to handle bot collections more robustly, trimming bot names to prevent whitespace issues and using `GetValueOrDefault` to avoid exceptions when a bot name is not found.
- Updated the `HandleInternalCollectCommand` method to return a more informative response, indicating the number of collected games and the bots involved in the operation.

These updates aim to enhance the stability and reliability of the free game collection feature in ASF.
@maxisoft maxisoft self-assigned this May 11, 2024
@maxisoft
Copy link
Owner

Hi @enutn,

The upcoming release will include a fix for the KeyNotFoundException you've encountered. This fix will prevent ASF from crashing under similar circumstances, but it's important to note that the ASFFreeGames plugin might still not claim the games for the specific account that triggered the issue.

To help us pinpoint the root cause, could you provide more information? For example:

  • Did you add, edit, or remove a bot while the plugin was running? If so, restarting the app might resolve the issue.
  • Does your bot name contain any special or unusual characters that might not be handled correctly?

Any additional details you can provide would be greatly appreciated to ensure a comprehensive solution.

Thanks for your understanding and cooperation.

Best,
Maxisoft

@maxisoft maxisoft added bug Something isn't working question Further information is requested labels May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants