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

Crash when attempting to open 'Query Hydrus' menu #34

Open
RubyRed404 opened this issue Jul 6, 2023 · 3 comments
Open

Crash when attempting to open 'Query Hydrus' menu #34

RubyRed404 opened this issue Jul 6, 2023 · 3 comments

Comments

@RubyRed404
Copy link

Hatate repeatedly crashes when attempting to open the 'Query Hydrus' menu.
Immediately when I click on the menu point, hatate crashes into the ground.

Have tried installing older hatate versions.
Have tried re-installing hatate.
Have tried restarting both hatate and hydrus.
Have not yet tried generating a new/different api key for hatate.
Yes, I have made sure the api key is correct.
It works when sending hatate found/and tagged files to hydrus.

It is only this one menu item that does not work, and this would be really important for my uses, as I have a lot of files I want to tag and having to go trough and add every single one of the 256 folders hydrus makes is not only an inefficient use of time, but also a waste of resources, as I'm importing a lot of files which are already tagged

The following log has been translated by deepL, as for some unbeknownst reason, the logs were printed in my computers native language, which is not english.

Crash Log System.Windows.Threading.DispatcherUnhandledExceptionEventArgs

The object cannot be converted from "Newtonsoft.Json.Linq.JObject" to "Newtonsoft.Json.Linq.JArray".

Hatate

System.Collections.ListDictionaryInternal

System.InvalidCastException: Object cannot be converted from type "Newtonsoft.Json.Linq.JObject" to type "Newtonsoft.Json.Linq.JArray".

in the following location: Hatate.HydrusQuery.d__7.MoveNext()

--- End of stack trace from the previous occurrence of the exception ---

in the following location: System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.b__6_0(Object state)

in the following location: System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)

in the following location: System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

in the following location: Hatate.HydrusQuery.d__7.MoveNext()

--- End of stack trace from the previous occurrence of the exception ---

at the next location: System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.b__6_0(Object state)

in the following location: System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)

in the following location: System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

@RubyRed404
Copy link
Author

Not sure if this is something that would help as I am a little out of my depth here but doing a quick search on the internet led me to this:
https://stackoverflow.com/questions/33495634/unable-to-cast-object-of-type-newtonsoft-json-linq-jobject-to-type-newtonsoft

Particularly this answer seems like a simple solution to the problem:
https://stackoverflow.com/a/73728816

Hopefully this can help someone here...
(if there is still anyone here..)

@terrehbyte
Copy link

Looks like at a glance that the Hydrus API has changed in a way that Hatate has not yet been updated to handle.

The technical details are simple: Hatate is trying to retrieve a list of what Hydrus calls services, like your "local files" service or "local files" service that house your data. It used to provide them directly in the query that Hatate is performing, but now it's provided as an array of children in the result. I get the same problem on ver538, though I'm not sure specifically when the API change happened.

I worked around it by updating the code on my copy on HydrusQuery.xaml.cs#146.

			foreach (var item in services) {
				string key = (string)item.Key;
-				JArray jArray = (JArray)item.Value;
+				IEnumerable<JObject> jArray = item.Value.Children<JObject>();

It might be more work for @nostrenz though if they want to support the older API scheme as well as the new one in the same build. I might submit a PR if I get the time and inclination to do so.

@nostrenz
Copy link
Owner

Hi! As you can see I was a little short on time to work on Hatate lastly.
I've published a new release implementing @terrehbyte's fix, and it should work for both the latest version of Hydrus as well as the older ones.

Sorry for the long wait, however I do appreciate those bug reports, so thanks for helping fixing/improving Hatate!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants