mvp-factory-openhands/SIMPLE_DATA_FIX.md

93 lines
2.2 KiB
Markdown

# 📚 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