From 12d852030731dc2d1c9a5e01462885a5afe7fea5 Mon Sep 17 00:00:00 2001 From: Git Admin Date: Mon, 1 Dec 2025 18:57:14 +0000 Subject: [PATCH] Add Node 7 troubleshooting guide for retry_count error --- TROUBLESHOOTING_NODE7.md | 118 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 TROUBLESHOOTING_NODE7.md diff --git a/TROUBLESHOOTING_NODE7.md b/TROUBLESHOOTING_NODE7.md new file mode 100644 index 0000000..1dafa47 --- /dev/null +++ b/TROUBLESHOOTING_NODE7.md @@ -0,0 +1,118 @@ +# 🔍 Node 7 "Format Build Response" - retry_count Error + +## 🎯 Error Message + +``` +Problem in node 'Format Build Response' +Cannot read properties of undefined (reading 'retry_count') +[line 12] +``` + +## 🔍 Root Cause + +Node 7 tries to access: +```javascript +retry_count: $workflow.staticData.retry_count || 0 +``` + +**The problem:** +- `$workflow.staticData` might be `undefined` on first execution +- Even if it exists, `retry_count` property might not be set yet +- Node 7 runs BEFORE Node 8 "Increment Retry Counter" on first attempt + +## 🛠️ Fix: Update Node 7 Code + +In n8n editor: +1. Open Node 7 **"Format Build Response"** +2. Replace the code with this **FIXED version**: + +```javascript +// FIXED: Properly handle undefined staticData +const repoInfo = $('Extract Repo Info').item.json; +const buildStatus = $('Check Build Status').item.json; + +// Safely get retry count from staticData +const retryCount = ($workflow.staticData && $workflow.staticData.retry_count) || 0; + +const result = { + status: buildStatus.status, + repo: repoInfo.repo_full_name, + branch: repoInfo.branch, + commit: repoInfo.commit_sha ? repoInfo.commit_sha.substring(0, 8) : 'N/A', + message: buildStatus.message, + timestamp: new Date().toISOString(), + retry_count: retryCount +}; + +// Add emoji for status +if (result.status === 'SUCCESS') { + result.emoji = '✅'; +} else if (result.status === 'FAILED') { + result.emoji = '❌'; +} else { + result.emoji = '⚠️'; +} + +return result; +``` + +### Key Changes: +1. ✅ **Safe access:** `($workflow.staticData && $workflow.staticData.retry_count) || 0` +2. ✅ **Default values:** Handle undefined properties gracefully +3. ✅ **Commit hash:** Add null check before `.substring()` + +## 🎯 What Will Happen After Fix + +**First execution (retry_count = 0):** +```json +{ + "status": "SUCCESS", + "emoji": "✅", + "repo": "gitadmin/test-repo", + "branch": "main", + "commit": "abc123", + "message": "Build completed successfully", + "timestamp": "2025-12-01T18:45:00.000Z", + "retry_count": 0 +} +``` + +**After retries (retry_count = 1, 2, or 3):** +```json +{ + "status": "SUCCESS", + "emoji": "✅", + "retry_count": 1, + ... +} +``` + +## 🔄 Alternative: Initialize staticData in Node 1 + +You can also add this to Node 1 "Extract Repo Info" to ensure staticData is initialized: + +```javascript +// Add at the start of Node 1 code: +if (!$workflow.staticData) { + $workflow.staticData = {}; +} +if ($workflow.staticData.retry_count === undefined) { + $workflow.staticData.retry_count = 0; +} + +// Then continue with original code... +``` + +## ✅ Testing + +After applying the fix: +1. Save workflow +2. Test with cURL: +```bash +curl -X POST https://n8n.oky.sh/webhook/openhands-enhanced \ + -H "Content-Type: application/json" \ + -d '{"repository": {"full_name": "test"}, "commits": [{"message": "Test"}]}' +``` + +3. Check n8n Executions tab - should complete without errors! +4. See JSON response with ✅ emoji in "Format Build Response" node