mob-sakai/UpmGitExtension

KeyNotFoundException is thrown for every package found when trying to install.

cookie966507 opened this issue ยท 12 comments

Describe the bug
KeyNotFoundException is thrown for every package found when trying to install.

KeyNotFoundException: The given key was not present in the dictionary.
System.Collections.Generic.Dictionary2[TKey,TValue].get_Item (TKey key) (at <7ba07f088431485bb722f3b3373e87ee>:0) Coffee.UpmGitExtension.PackageUtils+<>c__DisplayClass2_0.<InstallPackage>b__0 (System.Collections.Generic.Dictionary2[TKey,TValue] manifest) (at Library/PackageCache/com.coffee.upm-git-extension@1.1.0-preview.13/Editor/Coffee.UpmGitExtension/Utils.cs:136)
Coffee.UpmGitExtension.PackageUtils.UpdateManifestJson (System.Action1[T] action) (at Library/PackageCache/com.coffee.upm-git-extension@1.1.0-preview.13/Editor/Coffee.UpmGitExtension/Utils.cs:167) Coffee.UpmGitExtension.PackageUtils.InstallPackage (System.String packageName, System.String repoUrl, System.String refName) (at Library/PackageCache/com.coffee.upm-git-extension@1.1.0-preview.13/Editor/Coffee.UpmGitExtension/Utils.cs:126) Coffee.UpmGitExtension.InstallPackageWindow.onClick_InstallPackage () (at Library/PackageCache/com.coffee.upm-git-extension@1.1.0-preview.13/Editor/Coffee.UpmGitExtension/UI/InstallPackageWindow.cs:186) UnityEngine.Experimental.UIElements.Clickable.OnMouseUp (UnityEngine.Experimental.UIElements.MouseUpEvent evt) (at C:/buildslave/unity/build/Modules/UIElements/Clickable.cs:152) UnityEngine.Experimental.UIElements.EventCallbackFunctor1[TEventType].Invoke (UnityEngine.Experimental.UIElements.EventBase evt) (at C:/buildslave/unity/build/Modules/UIElements/Events/EventCallback.cs:62)
UnityEngine.Experimental.UIElements.EventCallbackRegistry.InvokeCallbacks (UnityEngine.Experimental.UIElements.EventBase evt) (at C:/buildslave/unity/build/Modules/UIElements/Events/EventCallbackRegistry.cs:376)
UnityEngine.Experimental.UIElements.CallbackEventHandler.HandleEvent (UnityEngine.Experimental.UIElements.EventBase evt) (at C:/buildslave/unity/build/Modules/UIElements/Events/EventHandler.cs:112)
UnityEngine.Experimental.UIElements.EventDispatcher.ProcessEvent (UnityEngine.Experimental.UIElements.EventBase evt, UnityEngine.Experimental.UIElements.IPanel panel) (at C:/buildslave/unity/build/Modules/UIElements/EventDispatcher.cs:511)
UnityEngine.Experimental.UIElements.EventDispatcher.Dispatch (UnityEngine.Experimental.UIElements.EventBase evt, UnityEngine.Experimental.UIElements.IPanel panel, UnityEngine.Experimental.UIElements.DispatchMode dispatchMode) (at C:/buildslave/unity/build/Modules/UIElements/EventDispatcher.cs:307)
UnityEngine.Experimental.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.Experimental.UIElements.EventBase e, UnityEngine.Experimental.UIElements.DispatchMode dispatchMode) (at C:/buildslave/unity/build/Modules/UIElements/Panel.cs:176)
UnityEngine.Experimental.UIElements.UIElementsUtility.DoDispatch (UnityEngine.Experimental.UIElements.BaseVisualElementPanel panel) (at C:/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:245)
UnityEngine.Experimental.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at C:/buildslave/unity/build/Modules/UIElements/UIElementsUtility.cs:68)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at C:/buildslave/unity/build/Modules/IMGUI/GUIUtility.cs:179)

To Reproduce
Steps to reproduce the behavior:

  1. Install the UpmGitExtension
  2. Create a repository and create a package to be imported (this repo is private)
  3. Click the Package Manager UPM orange button in the bottom left to add the package
  4. Enter the package repo url
  5. Search for the repo package
  6. Note that the package is found successfully
  7. Pick a version from the dropdown to install (all versions appear for me)
  8. Press the button to install the version
  9. Error is thrown in the console

Expected behavior
Package should be imported

Environment

  • Version 1.1.0 preview 13
  • Platform: Windows 10
  • Unity version: 2018.4.10

I'm also getting this bug.
Version 1.1.0 preview 13
Platform: Windows 10
Unity version: 2019.4.1f1

bguyl commented

Same here, in a private repository

Same here, in a gitlab private repository.
With both tag version or master version.

TCROC commented

@mob-sakai I can confirm that I'm also getting this error on this version. Do you have any idea what would be causing it?

TCROC commented

I looked into it. It is an easy fix. In the Utils.cs class on line 136, make the following change:

var locks = manifest["lock"] as Dictionary<string, object>;

to

var locks = manifest.TryGetValue("lock", out object lockValue) ? lockValue as Dictionary<string, object> : null;

Then everything works as expected :)

TCROC commented

@mob-sakai I opened up a pull request.

Sorry for the late reply.
Thanks for the PR!

TCROC commented

Sorry for the late reply.
Thanks for the PR!

@mob-sakai no problem! :). Glad I was able to help! Let me know when you trigger the release and Iโ€™ll test it out then we can close this issue.

TCROC commented

Hey @mob-sakai. When can we expect a release or preview release to be rolled out with this fix? Currently, this bug is breaking all of our private repos.

๐ŸŽ‰ This issue has been resolved in version 1.1.0-preview.14 ๐ŸŽ‰

The release is available on:

GitHub release
v1.1.0-preview.14
Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€

@TCROC
Sorry, I forgot to merge it into the preview branch!

TCROC commented

@mob-sakai @cookie966507 I think we are good to close this issue now