Error handling in Parse JSON action

Hello,

I am using the Parse JSON action to extract the output.content.text path from a ChatGPT response. When the ChatGPT call succeeded this works well.

The problem I have is when the ChatGPT call fails and therefore provides a different JSON structure. The Parse JSON action errors and I have to manually filter out the failed record so that the successful records can be parsed (annoying when debugging but impossible when scheduled).

Can you suggest how I handle these errors? Many EM actions will provide an error output for just the failed records but Parse JSON does not do that. Is there another action I can use before Parse JSON to identify and filter out the failed records?

Edit: Desktop version 5.9.1.7

Thanks

Hello @jonbailiss,

Can you please provide a sample JSON with both successful and failed records?

JSON from successful request:

{
"id": "resp_0921b7db279458cf0069d3ef39f4a481939fe8bd5e9bf3d8b3",
"object": "response",
"created_at": 1775497017,
"status": "completed",
"background": false,
"completed_at": 1775497020,
"content_filters": [
{
"blocked": false,
"source_type": "prompt",
"content_filter_raw": ,
"content_filter_results": {
"sexual": {
"filtered": false,
"severity": "safe"
},
"hate": {
"filtered": false,
"severity": "safe"
},
"violence": {
"filtered": false,
"severity": "safe"
},
"self_harm": {
"filtered": false,
"severity": "safe"
}
},
"content_filter_offsets": {
"start_offset": 339,
"end_offset": 425,
"check_offset": 0
}
},
{
"blocked": false,
"source_type": "completion",
"content_filter_raw": ,
"content_filter_results": {
"hate": {
"filtered": false,
"severity": "safe"
},
"violence": {
"filtered": false,
"severity": "safe"
},
"sexual": {
"filtered": false,
"severity": "safe"
},
"self_harm": {
"filtered": false,
"severity": "safe"
}
},
"content_filter_offsets": {
"start_offset": 0,
"end_offset": 713,
"check_offset": 0
}
}
],
"error": null,
"frequency_penalty": 0.0,
"incomplete_details": null,
"instructions": null,
"max_output_tokens": 1000,
"max_tool_calls": null,
"model": "gpt-5.2-chat",
"output": [
{
"id": "rs_0921b7db279458cf0069d3ef3a96d481938b86016f76d4a551",
"type": "reasoning",
"summary":
},
{
"id": "msg_0921b7db279458cf0069d3ef3b6d288193974907c1defc1f27",
"type": "message",
"status": "completed",
"content": [
{
"type": "output_text",
"annotations": ,
"logprobs": ,
"text": "[\n {\n "English": "Red",\n "French": "Rouge",\n "Italian": "Rosso"\n },\n {\n "English": "Orange",\n "French": "Orange",\n "Italian": "Arancione"\n },\n {\n "English": "Yellow",\n "French": "Jaune",\n "Italian": "Giallo"\n },\n {\n "English": "Green",\n "French": "Vert",\n "Italian": "Verde"\n },\n {\n "English": "Blue",\n "French": "Bleu",\n "Italian": "Blu"\n },\n {\n "English": "Indigo",\n "French": "Indigo",\n "Italian": "Indaco"\n },\n {\n "English": "Violet",\n "French": "Violet",\n "Italian": "Viola"\n }\n]"
}
],
"role": "assistant"
}
],
"parallel_tool_calls": true,
"presence_penalty": 0.0,
"previous_response_id": null,
"prompt_cache_key": null,
"prompt_cache_retention": null,
"reasoning": {
"effort": "medium",
"summary": null
},
"safety_identifier": null,
"service_tier": "auto",
"store": true,
"temperature": 1.0,
"text": {
"format": {
"type": "text"
},
"verbosity": "medium"
},
"tool_choice": "auto",
"tools": ,
"top_logprobs": 0,
"top_p": 0.85,
"truncation": "disabled",
"usage": {
"input_tokens": 52,
"input_tokens_details": {
"cached_tokens": 0
},
"output_tokens": 232,
"output_tokens_details": {
"reasoning_tokens": 0
},
"total_tokens": 284
},
"user": null,
"metadata": {
"version": "1.0"
}
}

JSON from a failed request:

{
"error": {
"message": "Unknown parameter: 'id'.",
"type": "invalid_request_error",
"param": "id",
"code": "unknown_parameter"
}
}

The Output.Content.Path keys do not exist so the action fails. If some of the request have been successful then I want to parse those and get an error message for the failures.

Hello @jonbailiss,

Thank you for the sample JSON.

First of all, if you are using the "Web request" action, you can turn on the "Add column with response code and headers" option and create a conditional workflow based on the response's HTTP status code.

Alternatively, you can use the "Extract JSON properties" action to extract the output and the error properties and then create a conditional workflow based on the value of the output property. Here is an example. You can see the behaviour in both cases by toggling the "Result" parameter.
Parse JSON example.morph (15.2 KB)