Hey there,
The error I am getting is TypeError: Object of type set is not JSON serializable
I have a step where I am passing 2 json arrays into a python step where i need to join the
My input -
{“solutions”:“["Convert Solution Query Results To JSON"].[json]”,“vulnerabilities”:“["Get-Adjusted-Vulns"].[items]”}
My function
def run(params={}):
Vulnerabilities1 = params.get(‘vulnerabilities’)
#solutions1 = params.get(‘solutions’)
json_string_variable = ‘{“name”: “Alice”, “age”: 30, “city”: “New York”}’
return {json_string_variable}
Obviously I am just trying to make sure the inputs and outputs work.
When testing the workflow, the input for the python step is:
{
“function”: “def run(params={}):\n Vulnerabilities1 = params.get(‘vulnerabilities’)\n #solutions1 = params.get(‘solutions’)\n json_string_variable = ‘{"name": "Alice", "age": 30, "city": "New York"}’\n return {json_string_variable}”,
“input”: {
“solutions”: “["Convert Solution Query Results To JSON"].[json]”,
“vulnerabilities”: “["Get-Adjusted-Vulns"].[items]”
},
“timeout”: 30
}
It seems to me if it was the json instead of the strings of the variables i would see JSON which means the value of the variable isn’t being passed in. What am i going wrong?
The error:
Traceback (most recent call last):
File “/workspace/.py”, line 28, in
sys.stdout.write(“” + json.dumps(run({‘solutions’: ‘[“Convert Solution Query Results To JSON”].[json]’, ‘vulnerabilities’: ‘[“Get-Adjusted-Vulns”].[items]’})))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/layers/paketo-buildpacks_cpython/cpython/lib/python3.12/json/init.py”, line 231, in dumps
return _default_encoder.encode(obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/layers/paketo-buildpacks_cpython/cpython/lib/python3.12/json/encoder.py”, line 200, in encode
chunks = self.iterencode(o, _one_shot=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/layers/paketo-buildpacks_cpython/cpython/lib/python3.12/json/encoder.py”, line 258, in iterencode
return _iterencode(o, 0)
^^^^^^^^^^^^^^^^^
File “/layers/paketo-buildpacks_cpython/cpython/lib/python3.12/json/encoder.py”, line 180, in default
raise TypeError(f’Object of type {o.class.name} ’
TypeError: Object of type set is not JSON serializable



