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 ArgumentException in ConsoleUI recommendations #2990

Merged
merged 1 commit into from
Feb 6, 2020

Conversation

HebaruSan
Copy link
Member

Problem

If you have a lot of modules installed, ConsoeUI's "audit recommendations" option can throw an exception:

[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: An item with the same key has already been added. Key: NearFutureConstruction 1.1.4
  at System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) [0x0015a] in <c4bddbfe864a4b8191bb818d6b204e9d>:0 
  at System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) [0x00000] in <c4bddbfe864a4b8191bb818d6b204e9d>:0 
  at CKAN.ConsoleUI.DependencyScreen.generateList (System.Collections.Generic.HashSet`1[T] inst) [0x001f4] in <ce28b1fd8caa4b339aed683ae3b21ffc>:0 
  at CKAN.ConsoleUI.DependencyScreen..ctor (CKAN.KSPManager mgr, CKAN.ConsoleUI.ChangePlan cp, System.Collections.Generic.HashSet`1[T] rej, System.Boolean dbg) [0x000ee] in <ce28b1fd8caa4b339aed683ae3b21ffc>:0 
  at CKAN.ConsoleUI.ModListScreen.ViewSuggestions () [0x0008d] in <ce28b1fd8caa4b339aed683ae3b21ffc>:0 
  at CKAN.ConsoleUI.Toolkit.ConsolePopupMenu.Run (System.Int32 right, System.Int32 top) [0x00162] in <ce28b1fd8caa4b339aed683ae3b21ffc>:0 
  at CKAN.ConsoleUI.Toolkit.ConsoleScreen.<.ctor>b__0_1 (System.Object sender) [0x00023] in <ce28b1fd8caa4b339aed683ae3b21ffc>:0 
  at CKAN.ConsoleUI.Toolkit.ScreenContainer.Interact () [0x0003e] in <ce28b1fd8caa4b339aed683ae3b21ffc>:0 
  at CKAN.ConsoleUI.Toolkit.ScreenContainer.Run (System.Action process) [0x0002b] in <ce28b1fd8caa4b339aed683ae3b21ffc>:0 
  at CKAN.ConsoleUI.ConsoleCKAN..ctor (CKAN.KSPManager mgr, System.Boolean debug) [0x0005b] in <ce28b1fd8caa4b339aed683ae3b21ffc>:0 
  at CKAN.ConsoleUI.ConsoleUI.Main_ (System.String[] args, CKAN.KSPManager manager, System.Boolean debug) [0x00007] in <ce28b1fd8caa4b339aed683ae3b21ffc>:0 
  at CKAN.CmdLine.MainClass.ConsoleUi (CKAN.KSPManager manager, CKAN.CmdLine.CommonOptions opts, System.String[] args) [0x00019] in <ce28b1fd8caa4b339aed683ae3b21ffc>:0 
  at CKAN.CmdLine.MainClass.RunSimpleAction (CKAN.CmdLine.Options cmdline, CKAN.CmdLine.CommonOptions options, System.String[] args, CKAN.IUser user, CKAN.KSPManager manager) [0x002ff] in <ce28b1fd8caa4b339aed683ae3b21ffc>:0 
  at CKAN.CmdLine.MainClass.Execute (CKAN.KSPManager manager, CKAN.CmdLine.CommonOptions opts, System.String[] args) [0x0028b] in <ce28b1fd8caa4b339aed683ae3b21ffc>:0 
  at CKAN.CmdLine.MainClass.Main (System.String[] args) [0x000a1] in <ce28b1fd8caa4b339aed683ae3b21ffc>:0 

Reported in #2986 (comment) .

Cause

ModuleInstaller.FindRecommendations can return a module in the suggested-by list that's also in the recommendations or sugggestions.

ConsoleUI.DependencyScreen puts all three lists into one dictionary keyed by the CkanModule, which causes exceptions to be thrown on duplicates.

Changes

Now ModuleInstaller.FindRecommendations excludes recommended and suggested modules from the supported-by list. No module will appear in more than one of the lists.

@HebaruSan HebaruSan added Bug Something is not working as intended Easy This is easy to fix Core (ckan.dll) Issues affecting the core part of CKAN Pull request Relationships Issues affecting depends, recommends, etc. ConsoleUI Issues affecting the interactive console UI labels Feb 6, 2020
@HebaruSan HebaruSan merged commit a44af7b into KSP-CKAN:master Feb 6, 2020
@HebaruSan HebaruSan deleted the fix/consoleui-rec-except branch February 6, 2020 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is not working as intended ConsoleUI Issues affecting the interactive console UI Core (ckan.dll) Issues affecting the core part of CKAN Easy This is easy to fix Relationships Issues affecting depends, recommends, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants