Fix compat issues with /jobs return values.

* ensure that both the return and info keys are lists.
* When the Result key doesn't match the expected shape,
  return an empty list of an empty dict (this matches existing
  behavior when looking for a non-existant JID).
This commit is contained in:
Scott Thrasher 2016-08-31 14:57:29 -07:00 committed by rallytime
parent 4778bc7365
commit 78dd629f09

View file

@ -1329,10 +1329,13 @@ class Jobs(LowDataAdapter):
ret = {}
if jid:
ret['info'] = job_ret_info[0]
ret['return'] = [dict((k, job_ret_info[0]['Result'][k]['return']) for k in job_ret_info[0]['Result'])]
ret['info'] = [job_ret_info[0]]
try:
ret['return'] = [dict((k, job_ret_info[0]['Result'][k]['return']) for k in job_ret_info[0]['Result'])]
except (TypeError, KeyError):
ret['return'] = [{}]
else:
ret['return'] = job_ret_info[0]
ret['return'] = [job_ret_info[0]]
return ret