when I use a code node in my workflow, that code node is not executing my code what I kept inside. Instead of that it is simply returning the previous node input as output. How I need to resolve this ?
[
{
“error”: “The connection cannot be established, this usually occurs due to an incorrect host (domain) value”
}
]
this is the input I am receiving from my previous node and I’m kept the below code for code node
from datetime import datetime
workflow_id_val = “{workflow_id}”
results =
for item in items:
try:
Get input JSON
input_data = item.get(“json”, {})
# Determine exit code
exit_code = 0
stderr = None
if 'error' in input_data and input_data['error']:
exit_code = 1
stderr = input_data['error']
elif 'stderr' in input_data and input_data['stderr']:
exit_code = 1
stderr = input_data['stderr']
elif 'exitCode' in input_data and input_data['exitCode'] != 0:
exit_code = input_data['exitCode']
stderr = input_data.get('stderr', 'Command failed with non-zero exit code')
# ⚡ Force overwrite all output fields
result = {
'dag_id': workflow_id_val,
'status': 'success' if exit_code == 0 else 'failed',
'last_run_time': datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S'),
'error': stderr
}
except Exception as e:
result = {
'dag_id': workflow_id_val,
'status': 'failed',
'last_run_time': datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S'),
'error': f'Exception: {str(e)}',
'debug_items': str(items)
}
# Always return result only — do not merge with old input
results.append({"json": result})
return results
now this code node has to return the json structure what I am returning but instead of that it is returning the previous node input
[
{
“error”: “The connection cannot be established, this usually occurs due to an incorrect host (domain) value”,
“myNewField”: 1
}
]
I’m thinking it is not executing my code so what could be the reason for this and how I can resolve ?
Describe the problem/error/question
What is the error message (if any)?
Please share your workflow
(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)
Share the output returned by the last node
Information on your n8n setup
- n8n version:
- Database (default: SQLite):
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- Running n8n via (Docker, npm, n8n cloud, desktop app):
- Operating system: