Made outputs response parsing and none handling more reliable.

This commit is contained in:
Lyncoln
2026-10-26 09:51:52 -04:00
parent 8846f467e6
commit 78e5b8fdf7
+32 -6
View File
@@ -1,12 +1,40 @@
import json
import requests
def buildOutput(response, action, outputs):
if hasattr(action, "outputs"):
if response is not None:
try:
if hasattr(response, "content"):
if not response.content:
return outputs
response_data = response.json()
except AttributeError:
else:
if not response:
return outputs
response_data = json.loads(response)
except (json.JSONDecodeError, requests.exceptions.JSONDecodeError) as error:
print(f"JSON decoding failed during {action.name}: {error}")
return outputs
#if response is not None:
# if not response.content:
# return outputs
#
# try:
# response_data = response.json()
# except AttributeError:
# response_data = json.loads(response)
if isinstance(response_data, list):
outputs["response_list"] = response_data
return outputs
response_objects = [response_data]
while response_objects:
@@ -22,10 +50,8 @@ def buildOutput(response, action, outputs):
outputs[output_name] = value
#print (response_data)
else:
print("No response received"),
#else:
# print("No response received"),
return outputs