-
-
Notifications
You must be signed in to change notification settings - Fork 455
Fix unparsed property #461
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
Conversation
|
It is also possible that this is caused by the fact that System.Text.Json is case sensitive, but it is supposed to work with camalcase with property. |
|
I think we can do a hot fix as @AnthonMS is relying on this right? |
|
I can just make my functions camelCase if that's the problem. I'm not quite sure what the problem is, since other python plugins work. |
No camelCase is not the problem. Would you please check the log? |
|
That's the problem, the logs don't show anything for the JsonRPCAction callback or anything. If I make a syntax error in the function I give through the JsonRPCAction, JsonRPCAction will send some error logs to the log file. But when I just execute the plugin I have linked a pastebin to on my issue, no errors occure in the logs. |
|
Are you able to get the result showing on the list? This patch fix the unexpected loss of the action callback stored in the result item. Sorry we didn't find that before. |
|
I get the results in flow, but the function is never called when I click on it. I test it by creating a file and writing a line to it. And it never does that. I dont know how I can test a function beyond that approach. My thought was to create a log file for my plugin where I could "Print" stuff, so I could debug a little easier. |
|
Also, when I set the JsonRPCAction "dontHideAfterAction": True. It still closes the Flow Launcher. So it's like the JsonRPCAction is being ignored completely. |
Yeah that's a bug, and this patch will fix it. Sorry for the bug. |
|
I tried using the PythonPluginTemplate test.py script, and there the result was this https://pastebin.com/zGYZ1tm7 So that's an example of what is being sent to flow and the result I get back. |
You don't have to say sorry, I'm a developer myself, so I know there will always be bugs until someone finds them :) Bit if I install the latest release 1.8.0, this issue will be fixed? And to update flow launcher, do I just download the new release and run it, or do I have to uninstall the old one? |
Just download it and run it. No need for uninstall the old one. |
@AnthonMS Yeah give the 1.8.0 pr build artifact a go or the one here in this pr, see if it fixes the problem, you can access it right? |
|
I don't believe 1.8.0 will be released by tonight, but you can try out our development branch. |
I can access the Release log and I can see the merge on the dev branch, but I'm uncertain how I will update it. Do I just download the .exe @taooceros have linked to? Because it's still names 1.7.2 |
|
@jjw24 Also I think there's a potential bug. When the action doesn't return anything, an error will be logged. Do we want to allow empty message when executing callback method?
yes |
The callback message, is that something I am doing wrong in my program, or is that a bug from FlowLauncher?
Okay, thanks for all the help! |
a bug from Flow, or a design limitation for executing api call. |
Maybe be consistent with c# plugin design where you can return empty list right? we do not need to log anything or treat it as an error, just return an empty list. |
No it is allowing empty list. I am talking about the message that should be print out for action callback. If the message is empty, Flow will consider something wrong happens. |
|
can you point me to the code please |
Sure, I am afk now. Will do that soon. |
|
Actually, you probably have more knowledge with this part of the code than I do, I will leave this to you how flow handles the empty message in this scenario |
protected string Execute(ProcessStartInfo startInfo)
{
try
{
using var process = Process.Start(startInfo);
if (process == null) return string.Empty;
using var standardOutput = process.StandardOutput;
var result = standardOutput.ReadToEnd();
if (string.IsNullOrEmpty(result))
{
using var standardError = process.StandardError;
var error = standardError.ReadToEnd();
if (!string.IsNullOrEmpty(error))
{
Log.Error($"|JsonRPCPlugin.Execute|{error}");
return string.Empty;
}
Log.Error("|JsonRPCPlugin.Execute|Empty standard output and standard error.");
return string.Empty;
}
if (result.StartsWith("DEBUG:"))
{
MessageBox.Show(new Form { TopMost = true }, result.Substring(6));
return string.Empty;
}
return result;
}
catch (Exception e)
{
Log.Exception(
$"|JsonRPCPlugin.Execute|Exception for filename <{startInfo.FileName}> with argument <{startInfo.Arguments}>",
e);
return string.Empty;
}
}The callback will call the exercute method, which will Log an error when the resulted print out is empty. |
|
Actually why would the result be empty? Shouldnt the plugin return an empty result object string(assuming that's what is returned)? |
Yeah they are supposed to return a template. |
|
Maybe we can mention that in the error log to make it clear? |
|
@jjw24 @taooceros I finally had time to test the hot fixed version of Flow Launcher. And now when I click on a action message I get this Exception Message Popup and the logs here. Can one of you decipher this error message for me? I don't seem to completely understand what the problem is. I have attached the log file, the exception message and I have run the test.py on it to see the result it sends back. Just did some more testing, I can see, even though I send paramters, the result it sends back does not contain any of the parameters. And it looks like the arguments aren't passed neither. So I'm pretty sure there's still some parsing errors. But now there's at least some error messages to go from. I'm not sure if this is the error you guys are talking about above. |
|
Hmmm for now, would you please check out the template for action callback and add that to the callback method? This exception means that Flow is trying to parse an empty string. |
I'm not quite sure I am following what I need to test. Do you mean use the sendActionMess function from here? But I think the empty string must be in the args, since the result I get back, has the arguments passed in the array, but it only have an empty string inside it in the callback method. That is the test result.txt I have linked to above. |
|
Sorry I was tired yesterday. Let me take a look on the code and I will reach out soon. |
|
The code suggests that you are supposed to return a JsonRPCRequestModel, which is the base class of the same ReponseModel that you are supposed to return with the Query, but just without the DontHideAfterAction, but I guess you can just use the same template, and that property will be ignored. So, you can either choose to use SendNormalMessage or SendActionMessage (when you want to execute Flow's api after the action). |
That is basically my code. I'm afk right now, so can't give det 100% correct. But the changes are only, in the query function I only call the sendActionMess and I pass the args as the only parameters. I then use the test.py from the python template. I hav only changed the query args in the test.py script to something like ["ha", "light", "entiry_id"] |
|
@taooceros Here you go, sorry for the wait, haven't had time to sit down at my computer all day. That is the ui.py (Main class). So I send the args in the subtitle string and in the parameters of the function I am calling. And both of the places in the result callback, it is empty lists. You can see the result json object I get in the callback here. |
|
I found the issue. It is because you have return the JSON parameters as Array>, which is like [["1","2","3"]], which makes Flow unable to correctly escape the string inside the inner array. I will try to replace Flow's self-built ToString method with the Json library and see whether that can handle the issue. |
|
Let me try editing it and check whether it should work. |
|
Hmmm There's a bug in flow causing this not working. System.Text.Json wraps the value with a JsonElement, which makes Flow unable to check it as string..... This is unexpected, and I will try fix it soon. |
|
@AnthonMS I add a fix to that. You can take a try if you want. I test your file, and it works both with [['']] and ['']. |
|
I will suppress the JsonError in a moment. |
I'm not at my computer at the moment and won't be until tonight again. But if you throw in a link to an artefact with the fix, I will give it a go when I have time. |
Getting the same exception message when using JsonRPCAction, is there a work-around? |
|
You can check the prerelease in the pinned discussion. That should include a fix for this. |
Thank you! Didn't realize the binary was there. That fixed all the issues I was having. |
|
No problem😉 |
It seems that System.Text.Json won't parse base class property? Add property name fix that. This change fix the broken python plugin callback.
#459
Do we want a hotfix for that (though we don't have much python plugin)?