Files
MobilityOps/n8n/workflows/fleet-ops-error-handler.json
T
NuklearRabbit 24dcb3494c
MobilityOps acceptance / backend (push) Failing after 47s
MobilityOps acceptance / frontend (push) Successful in 29s
MobilityOps acceptance / e2e (push) Skipped
M41: harden trust boundaries and delivery
2026-08-21 17:06:59 +02:00

106 lines
4.9 KiB
JSON

{
"id": "Xppn2rAEqUuyiCJF",
"name": "Fleet Ops — Workflow Error Handler",
"nodes": [
{
"parameters": {},
"id": "error-trigger-node",
"name": "Error Trigger",
"type": "n8n-nodes-base.errorTrigger",
"typeVersion": 1,
"position": [240, 300]
},
{
"parameters": {
"mode": "each",
"jsCode": "const err = $json.execution?.error || {};\nconst rawMessage = String(err.message || err.description || 'Unknown error').replace(/[\\r\\n]+/g, ' ').slice(0, 490);\nconst lower = rawMessage.toLowerCase();\nlet category = 'unknown';\nif (lower.includes('timeout') || lower.includes('timed out')) category = 'timeout';\nelse if (lower.includes('401') || lower.includes('403') || lower.includes('unauthorized') || lower.includes('forbidden')) category = 'authError';\nelse if (lower.includes('econnrefused') || lower.includes('enotfound') || lower.includes('network')) category = 'connectionError';\nelse if (/\\b[45]\\d\\d\\b/.test(rawMessage)) category = 'httpError';\nelse if (lower.includes('valid')) category = 'validationError';\nconst workflow = $json.workflow || {};\nconst execution = $json.execution || {};\nreturn {\n json: {\n workflow_id: String(workflow.id || 'unknown'),\n workflow_name: String(workflow.name || 'unknown'),\n execution_id: String(execution.id || ('unknown-' + Date.now())),\n failed_at: new Date().toISOString(),\n error_category: category,\n error_summary: rawMessage,\n trigger_context: String(execution.mode || 'unknown').slice(0, 200),\n correlation_id: null,\n attempt: execution.retryOf ? 2 : 1,\n retry_action: 'No automatic in-workflow retry. Check n8n execution history and the Fleet Ops Automation page for redelivery status.'\n }\n};"
},
"id": "build-report-node",
"name": "Build safe error report",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [500, 300]
},
{
"parameters": {
"method": "POST",
"url": "https://fleetops.itworx.tech/api/v1/integrations/n8n/workflow-error",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"sendBody": true,
"contentType": "json",
"specifyBody": "keypair",
"bodyParameters": {
"parameters": [
{ "name": "workflow_id", "value": "={{ $json.workflow_id }}" },
{ "name": "workflow_name", "value": "={{ $json.workflow_name }}" },
{ "name": "execution_id", "value": "={{ $json.execution_id }}" },
{ "name": "failed_at", "value": "={{ $json.failed_at }}" },
{ "name": "error_category", "value": "={{ $json.error_category }}" },
{ "name": "error_summary", "value": "={{ $json.error_summary }}" },
{ "name": "trigger_context", "value": "={{ $json.trigger_context }}" },
{ "name": "correlation_id", "value": "={{ $json.correlation_id }}" },
{ "name": "attempt", "value": "={{ $json.attempt }}" },
{ "name": "retry_action", "value": "={{ $json.retry_action }}" }
]
},
"options": {}
},
"id": "report-node",
"name": "Report failure to Fleet Ops",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [760, 300],
"credentials": {
"httpHeaderAuth": { "name": "Fleet Ops Service Token" }
}
},
{
"parameters": {
"method": "POST",
"url": "https://fleetops.itworx.tech/api/v1/integrations/n8n/heartbeat",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"sendBody": true,
"contentType": "json",
"specifyBody": "keypair",
"bodyParameters": { "parameters": [
{ "name": "workflow_id", "value": "={{ $workflow.id }}" },
{ "name": "workflow_name", "value": "={{ $workflow.name }}" },
{ "name": "execution_id", "value": "={{ $execution.id }}" },
{ "name": "status", "value": "succeeded" }
]},
"options": { "timeout": 15000 }
},
"id": "heartbeat-node",
"name": "Report workflow heartbeat",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [1020, 300],
"credentials": { "httpHeaderAuth": { "name": "Fleet Ops Service Token" } },
"retryOnFail": true,
"maxTries": 3,
"waitBetweenTries": 1000
}
],
"connections": {
"Error Trigger": {
"main": [[{ "node": "Build safe error report", "type": "main", "index": 0 }]]
},
"Build safe error report": {
"main": [[{ "node": "Report failure to Fleet Ops", "type": "main", "index": 0 }]]
},
"Report failure to Fleet Ops": {
"main": [[{ "node": "Report workflow heartbeat", "type": "main", "index": 0 }]]
}
},
"settings": {
"executionOrder": "v1"
},
"active": true,
"meta": {
"templateCredsSetupCompleted": false
},
"tags": []
}