Add simple step-by-step fix for Node 7 data issue

This commit is contained in:
Git Admin 2025-12-01 19:14:37 +00:00
parent 968a3629c2
commit d0c0aaccaf
2 changed files with 207 additions and 0 deletions

92
SIMPLE_DATA_FIX.md Normal file
View File

@ -0,0 +1,92 @@
# 📚 SIMPLE: How to Fix Node 7 Data
## 🔍 What's Happening:
**Node 2 creates data:**
```json
{
"repo_full_name": "gitadmin/test-repo",
"commit_sha": "abc123",
"task": "Build project...",
...
}
```
**Node 7 can't see this data!**
Why? Because **Node 3 (SSH) doesn't pass the data through**.
## ✅ SOLUTION: Check What Node 7 Actually Receives
### Step 1: Debug First
In Node 7, replace ALL code with:
```javascript
return $json;
```
This will show you exactly what data Node 7 receives.
### Step 2: Test
1. Save workflow
2. Execute workflow
3. Look at Node 7 output
**You'll see something like:**
```json
{
"status": "SUCCESS",
"message": "Build completed successfully",
"timestamp": "2025-12-01T..."
}
```
Notice: **No `repo_full_name` or `commit_sha`**
## 🛠️ REAL FIX: Store Data in workflow.staticData
### In Node 2 "Extract Repo Info", ADD at the top:
```javascript
// Store data in staticData so all nodes can access it
$workflow.staticData = $workflow.staticData || {};
$workflow.staticData.repo_info = {
repo_full_name: payload.repository?.full_name || 'unknown',
branch: payload.ref?.replace('refs/heads/', '') || 'main',
commit_sha: payload.after || '',
pusher: payload.pusher?.username || 'unknown'
};
```
### Then in Node 7, use:
```javascript
// Get data from staticData (not from $json)
const repoInfo = $workflow.staticData.repo_info || {};
const buildStatus = $json;
const result = {
status: buildStatus.status || 'SUCCESS',
repo: repoInfo.repo_full_name || 'unknown',
branch: repoInfo.branch || 'main',
commit: repoInfo.commit_sha ? repoInfo.commit_sha.substring(0, 8) : 'N/A',
message: buildStatus.message || 'Build completed',
timestamp: new Date().toISOString(),
retry_count: ($workflow.staticData.retry_count) || 0
};
if (result.status === 'SUCCESS') {
result.emoji = '✅';
} else if (result.status === 'FAILED') {
result.emoji = '❌';
}
return result;
```
## 🎯 Summary:
**The problem:** Node 3 (SSH) doesn't pass Node 2's data through
**The fix:** Store the data in `$workflow.staticData` in Node 2, then read it from staticData in Node 7
**StaticData** is like a shared storage that all nodes can access

115
STEP_BY_STEP_FIX.md Normal file
View File

@ -0,0 +1,115 @@
# 🎯 STEP-BY-STEP: Fix Node 7 Data (Follow Exactly)
## The Problem:
```
Node 2 has: repo_full_name = "gitadmin/test-repo"
Node 7 wants: repo_full_name
BUT: Node 3 loses the data! ❌
```
## The Solution:
**Store data in a "shared box" (staticData) that all nodes can access**
---
## STEP 1: Fix Node 2
1. Open **Node 2 "Extract Repo Info"**
2. Find this line in the code:
```javascript
return {
repo_name: repoName,
repo_full_name: repoFullName,
...
};
```
3. **ADD THESE LINES BEFORE the return statement:**
```javascript
// NEW: Store data in shared storage
$workflow.staticData = $workflow.staticData || {};
$workflow.staticData.repo_info = {
repo_name: repoName,
repo_full_name: repoFullName,
repo_clone_url: repoCloneUrl,
branch: branch,
commit_sha: commitSha,
commit_message: commitMessage,
pusher: pusher
};
```
4. **Keep the existing return statement too** (don't delete it)
---
## STEP 2: Fix Node 7
1. Open **Node 7 "Format Build Response"**
2. **REPLACE ALL CODE** with:
```javascript
// NEW: Read from shared storage
const repoInfo = $workflow.staticData.repo_info || {};
const buildStatus = $json;
const result = {
status: buildStatus.status || 'SUCCESS',
repo: repoInfo.repo_full_name || 'unknown',
branch: repoInfo.branch || 'main',
commit: repoInfo.commit_sha ? repoInfo.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
};
if (result.status === 'SUCCESS') {
result.emoji = '✅';
} else if (result.status === 'FAILED') {
result.emoji = '❌';
} else {
result.emoji = '⚠️';
}
return result;
```
---
## STEP 3: Save and Test
1. Click **Save** (top-right)
2. Test with curl:
```bash
curl -X POST https://n8n.oky.sh/webhook/openhands-enhanced \
-H "Content-Type: application/json" \
-d '{"repository": {"full_name": "gitadmin/test-repo"}, "commits": [{"message": "Test"}]}'
```
3. Check n8n Executions → Node 7 output
---
## Expected Result:
```json
{
"status": "SUCCESS",
"repo": "gitadmin/test-repo", ← NOW SHOWS ACTUAL NAME!
"branch": "main",
"commit": "abc12345", ← NOW SHOWS ACTUAL COMMIT!
"message": "Build completed successfully",
"emoji": "✅"
}
```
---
## Visual Summary:
```
Node 2: Creates data → Saves to "shared box" ($workflow.staticData)
Node 3: SSH runs → (data stays in shared box)
Node 7: Reads from "shared box" → Has all data! ✅
```
The "shared box" (staticData) persists across all nodes!