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

"Key not found"-exception on selecting mods #2416

Closed
DasSkelett opened this issue Apr 22, 2018 · 10 comments
Closed

"Key not found"-exception on selecting mods #2416

DasSkelett opened this issue Apr 22, 2018 · 10 comments
Labels
GUI Issues affecting the interactive GUI Needs more info We need more info

Comments

@DasSkelett
Copy link
Member

DasSkelett commented Apr 22, 2018

Background

CKAN Version:
v1.25.1 (self-built and changed some layout stuff experimenting with little GUI changes to prevent Visual Studio changing the designer code every time you open the main form, so my changes shouldn't be relevant to this error)

KSP Version:
1.4.2.2110

Operating System:
Windows 10 64bit

Have you made any manual changes to your GameData folder (i.e., not via CKAN)?
no

Problem

What steps did you take in CKAN?
For testing some graphical improvements I tried, I downloaded a mod (with a suggested mod) to see the changeset tab. I accidently clicked cancel during the installation process, but it seemed to have it installed completely nevertheless.
So as I tried to uninstall it again, CKAN threw the following error every time I select either the same mod for Uninstall or other mods for Install.

What did you expect to happen?
Install / uninstall mod without errors.

What happened instead?
CKAN throws error on every Install-Checkbox click.

CKAN error codes (if applicable):

System.Collections.Generic.KeyNotFoundException: Der angegebene Schlüssel war nicht im Wörterbuch angegeben.
   bei System.ThrowHelper.ThrowKeyNotFoundException()
   bei System.Collections.Generic.Dictionary\`2.get_Item(TKey key)
   bei CKAN.MainModList.<ComputeChangeSetFromModList>d__29.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   bei CKAN.Main.<UpdateChangeSetAndConflicts>d__55.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   bei System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   bei CKAN.Main.<ModList_CellValueChanged>d__240.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

@DasSkelett DasSkelett changed the title Key not found exception on selecting mods "Key not found"-exception on selecting mods Apr 22, 2018
@HebaruSan HebaruSan added Bug Something is not working as intended GUI Issues affecting the interactive GUI labels Apr 22, 2018
@HebaruSan
Copy link
Member

The stack trace suggests this line, as installed_modules is the only notable Dictionary in the function:

CKAN/GUI/MainModList.cs

Lines 617 to 618 in 9e71f86

CkanModule module_by_version = registry.GetModuleByVersion(installed_modules[dependency].identifier,
installed_modules[dependency].version) ?? registry.InstalledModule(dependency).Module;

Populated here:

CKAN/GUI/MainModList.cs

Lines 576 to 577 in 9e71f86

var installed_modules =
registry.InstalledModules.Select(imod => imod.Module).ToDictionary(mod => mod.identifier, mod => mod);

That line is looking for mods that depend on mods being removed, and the exception suggests they're missing. Maybe registry.InstalledModules is in an inconsistent state, with missing dependencies? This is where the exact steps and mod names involved would be very helpful.

Sorry, something went wrong.

@HebaruSan
Copy link
Member

HebaruSan commented Apr 22, 2018

Alternately, it's also possible that the registry is fine but the GUI has a problem. If the mod isn't really installed, but GUI thinks it is, then GUI might be attempting to uninstall a mod that isn't installed, which could also conceivably cause this.

EDIT: Scratch that, Registry.FindReverseDependencies works by removing the given mod from the list and then scanning it for mods with missing dependencies. GUI would not be able to impose its view of installed mods on that function, so we're probably looking at a problem internal to the registry.

Sorry, something went wrong.

@DasSkelett
Copy link
Member Author

Ouf, which mod was it...
I think it's been "Almost Free Launch Clamps", but I'm not sure. It's been some mod beginning with an A and having one suggested mod listed (not sure about dependencies).

After a restart, everything worked fine.
It might be relevant, that the error was thrown every time I selected (just clicking on the checkbox, not clicking Apply button) the same mod (for uninstall) or another mod for install.

@HebaruSan
Copy link
Member

On further inspection, I think I pinpointed the wrong line above. installed_modules is a verbatim copy of registry.InstalledModules, and FindReverseDependencies uses that same list to generate its return values. So it shouldn't be logically possible for those installed_modules[dependency] references to throw.

@HebaruSan
Copy link
Member

@DasSkelett, are you able to make this happen at will? I tried cancelling the installation of Almost Free Launch Clamps, but I didn't encounter any exceptions. There are some debugging statements built into this code path that might be enlightening to see with logging enabled.

@DasSkelett
Copy link
Member Author

Going to try it.

@DasSkelett
Copy link
Member Author

DasSkelett commented Apr 22, 2018

Meanwhile some thoughts during waiting for CKAN (because DEBUG logging is hell!) and tracking the log:
Is it really needed to test for every version of every mod if it's compatible with the installed KSP version on every modlist update? So after each startup and each installation, CKAN does all those checks again.
Wouldn't it be sufficient to test for compatibility when you open the "Versions"-tab on the sidebar and, of course, before installing?


Furthermore, looking in the log, it seems to check every mod twice for compatibility?

I uploaded my log here (nothing new to the original issue yet!)

@HebaruSan
Copy link
Member

Going to try it.

Any luck getting this to happen again? I'm reviewing some old issues, and it looks like we never got to the bottom of this one.

@HebaruSan HebaruSan added the Needs more info We need more info label Dec 2, 2018
@DasSkelett
Copy link
Member Author

DasSkelett commented Dec 5, 2018

Hey, back again, sorry for the long wait. I took my A-levels(?, Abitur in German) earlier this year and was traveling during summer.
I remember that I didn't get this error to show up again, weird. Seems that you have to press cancel just the right millisecond to trigger this issue.

@DasSkelett
Copy link
Member Author

Since there have been a bunch of releases in between and the error never showed up again, I'll close this issue.

@DasSkelett DasSkelett removed the Bug Something is not working as intended label Apr 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GUI Issues affecting the interactive GUI Needs more info We need more info
Projects
None yet
Development

No branches or pull requests

2 participants