salt-netapi-client icon indicating copy to clipboard operation
salt-netapi-client copied to clipboard

Got com.google.gson.JsonSyntaxException: java.lang.IllegalStateException when I try to get the job info with a Invalid JobId

Open wheniworking opened this issue 8 years ago • 3 comments
trafficstars

I use Jobs.listJob(jid).callSync(saltClient) to get the JobInfo . If the jid is invalid for example 123 , I will get a IllegalStateException . com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_ARRAY at line 1 column 107 path $.return[0].Target-type However i run the command in shell $ salt-run jobs.list_job 123

I will get the result like this: Arguments: Function: unknown-function Result: ---------- StartTime: Target: unknown-target Target-type: User: root jid: 123

wheniworking avatar Mar 08 '17 11:03 wheniworking

What would be an appropriate return value in this case?

Maybe Jobs.listJob could return an Optional value? Or throwing a more informative exception?

ghost avatar Mar 13 '17 11:03 ghost

Duplicate of #190

admd avatar Mar 13 '17 11:03 admd

looks like the problem here is that

{
    "Function": "unknown-function",
    "jid": 1,
    "Result": {},
    "Target": "unknown-target",
    "StartTime": "",
    "Target-type": [],
    "Arguments": [],
    "User": "root"
}

Target-type is suddenly an array instead of a String. I see no reason for it being an array so i suspect a bug in salt.

lucidd avatar Mar 13 '17 13:03 lucidd