Add final fix for Node 7 data reference issue

This commit is contained in:
Git Admin 2025-12-01 19:10:59 +00:00
parent 02bab16f0b
commit 968a3629c2
1 changed files with 92 additions and 0 deletions

92
FINAL_FIX_NODE7.md Normal file
View File

@ -0,0 +1,92 @@
# 🎯 FINAL FIX: Node 7 Data Reference
## ❌ Current Broken Code in Node 7:
```javascript
const repoInfo = $node["Extract Repo Info"].json;
const buildStatus = $json;
```
This doesn't work because `$node["Extract Repo Info"]` is not the correct syntax.
## ✅ CORRECT FIX:
Replace **ALL** the code in Node 7 with this:
```javascript
// Method 1: Use the data that flows from Node 6
// Node 6 should have received data from Node 2 through the flow
const buildStatus = $json;
const repoInfo = $json; // Same item - should have all fields
// If data is not in $json, try this alternative:
const item = $input.item.json;
// Build the response
const result = {
status: buildStatus.status || 'SUCCESS',
repo: item.repo_full_name || 'unknown',
branch: item.branch || 'main',
commit: item.commit_sha ? item.commit_sha.substring(0, 8) : 'N/A',
message: buildStatus.message || 'Build completed',
timestamp: new Date().toISOString(),
retry_count: ($workflow.staticData && $workflow.staticData.retry_count) || 0
};
// Add emoji
if (result.status === 'SUCCESS') {
result.emoji = '✅';
} else if (result.status === 'FAILED') {
result.emoji = '❌';
} else {
result.emoji = '⚠️';
}
return result;
```
## 🔍 Alternative: Check What Data Node 6 Has
In n8n execution view:
1. Click on **Node 6 "Check Build Status"**
2. Look at its **Output**
3. Does it show `repo_full_name`, `commit_sha`, etc.?
If **YES** → Use Method 1 above
If **NO** → Node 6 needs to pass the data through
## 🛠️ Quick Test:
Simplify Node 7 to just see what's available:
```javascript
// Debug: See what's in the data
return {
debug: true,
available_data_keys: Object.keys($json),
all_data: $json,
timestamp: new Date().toISOString()
};
```
This will show you exactly what data is available.
## 🎯 Expected Result After Fix:
```json
{
"status": "SUCCESS",
"repo": "gitadmin/test-repo", ← Actual repo name
"branch": "main",
"commit": "abc12345", ← Actual commit
"message": "Build completed successfully",
"timestamp": "2025-12-01T19:04:55.473Z",
"retry_count": 0,
"emoji": "✅"
}
```
## 💡 Why It's Not Working:
The `$node["Node Name"]` syntax is incorrect for n8n code nodes.
Use `$json` or `$input.item.json` to access the current item data.