Cleanup: Remove 7 redundant .md documentation files
- SIMPLE_DATA_FIX.md (superseded by N8N_DATA_PRESERVATION_SOLUTION.md) - STEP_BY_STEP_FIX.md (superseded by N8N_DATA_PRESERVATION_SOLUTION.md) - MANUAL_N8N_FIX.md (superseded by N8N_DATA_PRESERVATION_SOLUTION.md) - TROUBLESHOOTING_NODE5.md (old debugging doc) - TROUBLESHOOTING_NODE7.md (old debugging doc) - TROUBLESHOOTING_UNKNOWN.md (old debugging doc) - IMPORT_FIXED_WORKFLOW.md (outdated import instructions) Keeps only essential, current documentation (9 files total)
This commit is contained in:
parent
a4e94695d9
commit
4b31b3eeb8
|
|
@ -1,93 +0,0 @@
|
|||
# 🎉 FIXED Enhanced CI/CD Workflow - Ready to Import!
|
||||
|
||||
## 📁 **File Location:**
|
||||
`openhands-enhanced-FIXED.json`
|
||||
|
||||
## ✅ **All Fixes Included:**
|
||||
|
||||
1. **Node 2 (Extract Repo Info):**
|
||||
- ✅ Stores repo data in `$workflow.staticData`
|
||||
- ✅ All nodes can now access the data
|
||||
|
||||
2. **Node 5 (Check Build Status):**
|
||||
- ✅ Always returns SUCCESS (no more false FAILED)
|
||||
- ✅ Clean logic for demo/testing
|
||||
|
||||
3. **Node 7 (Format Build Response):**
|
||||
- ✅ Reads repo data from `staticData`
|
||||
- ✅ Safe access to `retry_count` (handles undefined)
|
||||
- ✅ Shows actual repo name and commit instead of "unknown"
|
||||
|
||||
## 🚀 **How to Import:**
|
||||
|
||||
### Step 1: Download the File
|
||||
From the repository, get: `openhands-enhanced-FIXED.json`
|
||||
|
||||
### Step 2: Import to n8n
|
||||
1. Go to: https://n8n.oky.sh
|
||||
2. Click **"Workflows"** in top navigation
|
||||
3. Click **"Import from file"** button
|
||||
4. Select the `openhands-enhanced-FIXED.json` file
|
||||
5. Click **"Import"**
|
||||
|
||||
### Step 3: Activate
|
||||
1. Open the imported workflow
|
||||
2. Click the **toggle** (top-right) to set to **ACTIVE**
|
||||
3. Workflow name: **"Gitea → OpenHands Enhanced CI/CD - FIXED"**
|
||||
|
||||
### Step 4: Test
|
||||
```bash
|
||||
curl -X POST https://n8n.oky.sh/webhook/openhands-enhanced \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"repository": {
|
||||
"name": "test-repo",
|
||||
"full_name": "gitadmin/test-repo"
|
||||
},
|
||||
"ref": "refs/heads/main",
|
||||
"commits": [{"message": "Test"}]
|
||||
}'
|
||||
```
|
||||
|
||||
## 🎯 **Expected Result:**
|
||||
|
||||
**Check in n8n Executions tab → Node 7 output:**
|
||||
```json
|
||||
{
|
||||
"status": "SUCCESS",
|
||||
"repo": "gitadmin/test-repo", ← Actual repo name! ✅
|
||||
"branch": "main",
|
||||
"commit": "abc12345", ← Actual commit! ✅
|
||||
"message": "Build completed successfully",
|
||||
"timestamp": "2025-12-01T19:xx:xx.xxxZ",
|
||||
"retry_count": 0,
|
||||
"emoji": "✅"
|
||||
}
|
||||
```
|
||||
|
||||
## 📊 **What Changed:**
|
||||
|
||||
| Issue | Before | After |
|
||||
|-------|--------|-------|
|
||||
| Node 5 Status | ❌ FAILED (false positive) | ✅ SUCCESS |
|
||||
| Repo Name | ❌ "unknown" | ✅ "gitadmin/test-repo" |
|
||||
| Commit | ❌ "N/A" | ✅ "abc12345" |
|
||||
| retry_count | ❌ Error | ✅ "0" |
|
||||
|
||||
## 🎓 **Key Learnings:**
|
||||
|
||||
- **staticData** is shared across all nodes
|
||||
- Node references like `$('Node Name')` don't work in n8n v2
|
||||
- Use `$workflow.staticData` for persistent data
|
||||
- Always test with simple cases first!
|
||||
|
||||
## 📚 **Documentation Files:**
|
||||
- `PHASE3_ENHANCED_WORKFLOW.md` - Complete workflow overview
|
||||
- `STEP_BY_STEP_FIX.md` - Manual fix instructions
|
||||
- `TROUBLESHOOTING_*.md` - Various issue guides
|
||||
- `IMPORT_FIXED_WORKFLOW.md` - This file
|
||||
|
||||
## ✅ **Status:**
|
||||
**WORKFLOW IS PRODUCTION READY!**
|
||||
|
||||
**Webhook URL:** `https://n8n.oky.sh/webhook/openhands-enhanced`
|
||||
|
|
@ -1,156 +0,0 @@
|
|||
# 🔧 MANUAL FIX - Follow These EXACT Steps
|
||||
|
||||
## The Problem:
|
||||
`Cannot set properties of undefined (setting 'repo_info')`
|
||||
|
||||
**Root Cause:** `$workflow.staticData` doesn't work in n8n code nodes the way we're using it.
|
||||
|
||||
---
|
||||
|
||||
## SOLUTION: Remove staticData Completely
|
||||
|
||||
### Step 1: Open n8n Workflow
|
||||
1. Go to: https://n8n.oky.sh
|
||||
2. Open: **"Gitea → OpenHands Enhanced CI/CD"** workflow
|
||||
3. You should see all the nodes in a flow
|
||||
|
||||
### Step 2: Fix Node 2 - "Extract Repo Info"
|
||||
1. **Click on Node 2** (the blue code node)
|
||||
2. **Find the JavaScript code** (should be in a text area)
|
||||
3. **REPLACE THE ENTIRE CODE** with this:
|
||||
|
||||
```javascript
|
||||
// Extract repository and commit information from Gitea webhook
|
||||
const payload = $input.item.json;
|
||||
|
||||
// Extract key information
|
||||
const repoName = payload.repository?.name || 'unknown';
|
||||
const repoFullName = payload.repository?.full_name || 'unknown';
|
||||
const repoCloneUrl = payload.repository?.clone_url || '';
|
||||
const branch = payload.ref?.replace('refs/heads/', '') || 'main';
|
||||
const commitSha = payload.after || '';
|
||||
const commitMessage = payload.commits?.[0]?.message || 'No message';
|
||||
const pusher = payload.pusher?.username || 'unknown';
|
||||
|
||||
// Create task message for OpenHands SDK
|
||||
const task = 'Build and test project ' + repoFullName + ' on branch ' + branch + '. ' +
|
||||
'Latest commit: "' + commitMessage + '". ' +
|
||||
'Clone the repository from ' + repoCloneUrl + ' and run: npm install && npm test && npm build. ' +
|
||||
'Report any errors found.';
|
||||
|
||||
// IMPORTANT: Just return the data - it will flow to the next node
|
||||
return {
|
||||
repo_name: repoName,
|
||||
repo_full_name: repoFullName,
|
||||
repo_clone_url: repoCloneUrl,
|
||||
branch: branch,
|
||||
commit_sha: commitSha,
|
||||
commit_message: commitMessage,
|
||||
pusher: pusher,
|
||||
task: task,
|
||||
timestamp: new Date().toISOString(),
|
||||
status: 'PENDING',
|
||||
retry_count: 0
|
||||
};
|
||||
```
|
||||
|
||||
4. **Click "Update"** or **Save**
|
||||
|
||||
### Step 3: Fix Node 7 - "Format Build Response"
|
||||
1. **Click on Node 7** (later in the flow)
|
||||
2. **Find the JavaScript code**
|
||||
3. **REPLACE THE ENTIRE CODE** with this:
|
||||
|
||||
```javascript
|
||||
// Use the data from $json (which has everything from previous nodes)
|
||||
const item = $json;
|
||||
|
||||
const result = {
|
||||
status: item.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: item.message || 'Build completed',
|
||||
timestamp: new Date().toISOString(),
|
||||
retry_count: 0
|
||||
};
|
||||
|
||||
// Add emoji based on status
|
||||
if (result.status === 'SUCCESS') {
|
||||
result.emoji = '✅';
|
||||
} else if (result.status === 'FAILED') {
|
||||
result.emoji = '❌';
|
||||
} else {
|
||||
result.emoji = '⚠️';
|
||||
}
|
||||
|
||||
return result;
|
||||
```
|
||||
|
||||
4. **Click "Update"** or **Save**
|
||||
|
||||
### Step 4: Save the Entire Workflow
|
||||
1. Click **"Save"** (top-right of the workflow editor)
|
||||
2. Make sure the workflow is **ACTIVE** (toggle switch should be green/blue)
|
||||
|
||||
### Step 5: Test It
|
||||
1. Click **"Execute Workflow"** button (top-right)
|
||||
2. Use this test data:
|
||||
|
||||
```json
|
||||
{
|
||||
"repository": {
|
||||
"name": "test-repo",
|
||||
"full_name": "gitadmin/test-repo",
|
||||
"clone_url": "https://git.oky.sh/gitadmin/test-repo.git"
|
||||
},
|
||||
"ref": "refs/heads/main",
|
||||
"after": "abc123def456",
|
||||
"commits": [{"message": "Test webhook with real data"}],
|
||||
"pusher": {"username": "gitadmin"}
|
||||
}
|
||||
```
|
||||
|
||||
3. **Click "Execute Workflow"**
|
||||
|
||||
### Step 6: Check the Result
|
||||
Look at **Node 7 "Format Build Response"** output. You should see:
|
||||
|
||||
```json
|
||||
{
|
||||
"status": "SUCCESS",
|
||||
"repo": "gitadmin/test-repo", ← REAL REPO NAME! ✅
|
||||
"branch": "main",
|
||||
"commit": "abc12345", ← REAL COMMIT! ✅
|
||||
"message": "Build completed successfully",
|
||||
"timestamp": "2025-12-01T19:xx:xx.xxxZ",
|
||||
"retry_count": 0,
|
||||
"emoji": "✅"
|
||||
}
|
||||
```
|
||||
|
||||
### Step 7: Export the Working Workflow
|
||||
1. In n8n, go to the workflow editor
|
||||
2. Click **"..." menu** (three dots, top-right)
|
||||
3. Select **"Export"**
|
||||
4. Download the JSON file
|
||||
5. **Upload it to the repository** as `openhands-enhanced-WORKING.json`
|
||||
|
||||
---
|
||||
|
||||
## What Changed:
|
||||
|
||||
**BEFORE (Broken):**
|
||||
- Node 2: Tried to use `$workflow.staticData.repo_info = {...}` ❌
|
||||
- Node 7: Tried to read `$workflow.staticData.repo_info` ❌
|
||||
|
||||
**AFTER (Working):**
|
||||
- Node 2: Just returns data (flows to next node) ✅
|
||||
- Node 7: Reads data from `$json` ✅
|
||||
|
||||
**The Fix:** Data flows through nodes normally using `$json`, no staticData needed!
|
||||
|
||||
---
|
||||
|
||||
## Need Help?
|
||||
After testing, export the working workflow and I'll add it to the repository for you!
|
||||
|
|
@ -1,92 +0,0 @@
|
|||
# 📚 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
|
||||
|
|
@ -1,115 +0,0 @@
|
|||
# 🎯 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!
|
||||
|
|
@ -1,126 +0,0 @@
|
|||
# 🔍 Node 5 "Check Build Status" - FAILED Status Issue
|
||||
|
||||
## 🎯 The Problem
|
||||
|
||||
Node 5 is returning:
|
||||
```json
|
||||
{
|
||||
"status": "FAILED",
|
||||
"message": "Build failed - errors detected in task",
|
||||
"build_output": "Build completed with status: FAILED"
|
||||
}
|
||||
```
|
||||
|
||||
## 🔍 Root Cause
|
||||
|
||||
The **"Check Build Status" node has faulty logic**:
|
||||
|
||||
```javascript
|
||||
// CURRENT (BROKEN) LOGIC:
|
||||
const task = $('Extract Repo Info').item.json.task;
|
||||
const hasErrors = task.includes('error') || task.includes('failed');
|
||||
|
||||
if (hasErrors) {
|
||||
status = 'FAILED';
|
||||
message = 'Build failed - errors detected in task';
|
||||
}
|
||||
```
|
||||
|
||||
**The task message says:** "Report any errors found"
|
||||
**The word "error" is present → Status = FAILED ❌**
|
||||
|
||||
## ✅ **Current Status**
|
||||
|
||||
- ✅ Node 1 (Webhook): Working
|
||||
- ✅ Node 2 (Extract Repo Info): Working
|
||||
- ✅ Node 3 (SSH/OpenHands): Working
|
||||
- ✅ Node 4 (Wait 10s): Working
|
||||
- ❌ **Node 5 (Check Build Status): BROKEN - False FAILED status**
|
||||
- ⏳ Node 6 (Should Retry?): Waiting for correct status
|
||||
|
||||
## 🛠️ Fix: Update Node 5 Logic
|
||||
|
||||
In n8n editor, open the workflow:
|
||||
1. Click on **Node 5 "Check Build Status"**
|
||||
2. Replace the JavaScript code with:
|
||||
|
||||
### Option 1: Always Return SUCCESS (for testing)
|
||||
```javascript
|
||||
return {
|
||||
status: 'SUCCESS',
|
||||
message: 'Build completed successfully',
|
||||
timestamp: new Date().toISOString(),
|
||||
build_output: 'Build completed with status: SUCCESS'
|
||||
};
|
||||
```
|
||||
|
||||
### Option 2: Check for REAL Errors
|
||||
```javascript
|
||||
// Check for actual error indicators, not just the word "error"
|
||||
const task = $('Extract Repo Info').item.json.task;
|
||||
const hasBuildWords = task.includes('build') || task.includes('test') || task.includes('clone');
|
||||
const hasErrorKeywords = task.includes('npm install failed') || task.includes('npm test failed');
|
||||
|
||||
// For demo: return SUCCESS unless specific error indicators
|
||||
let status = 'SUCCESS';
|
||||
let message = 'Build completed successfully';
|
||||
|
||||
if (hasErrorKeywords) {
|
||||
status = 'FAILED';
|
||||
message = 'Build failed - specific errors detected';
|
||||
}
|
||||
|
||||
return {
|
||||
status: status,
|
||||
message: message,
|
||||
timestamp: new Date().toISOString(),
|
||||
build_output: 'Build completed with status: ' + status
|
||||
};
|
||||
```
|
||||
|
||||
### Option 3: Random Success/Failure (50/50)
|
||||
```javascript
|
||||
// For testing retry logic
|
||||
const isSuccess = Math.random() > 0.5;
|
||||
|
||||
return {
|
||||
status: isSuccess ? 'SUCCESS' : 'FAILED',
|
||||
message: isSuccess ? 'Build completed successfully' : 'Build failed - test failure',
|
||||
timestamp: new Date().toISOString(),
|
||||
build_output: 'Build completed with status: ' + (isSuccess ? 'SUCCESS' : 'FAILED')
|
||||
};
|
||||
```
|
||||
|
||||
## 🎯 Recommended Action
|
||||
|
||||
**Use Option 1** to get a working demo:
|
||||
1. Edit Node 5
|
||||
2. Replace all code with Option 1
|
||||
3. Save workflow
|
||||
4. Test again
|
||||
|
||||
## 📊 What Will Happen
|
||||
|
||||
**Before Fix:**
|
||||
```
|
||||
Node 5: status = FAILED (because task says "Report any errors")
|
||||
→ Goes to retry loop
|
||||
→ Keeps retrying indefinitely
|
||||
```
|
||||
|
||||
**After Fix:**
|
||||
```
|
||||
Node 5: status = SUCCESS
|
||||
→ Skips retry loop
|
||||
→ Goes to "Format Build Response"
|
||||
→ Returns: {"status": "SUCCESS", "emoji": "✅", ...}
|
||||
→ Workflow complete! ✅
|
||||
```
|
||||
|
||||
## 🔄 Testing Retry Logic
|
||||
|
||||
If you want to test the retry logic:
|
||||
1. Use **Option 3** (Random Success/Failure)
|
||||
2. Each execution has 50% chance of SUCCESS
|
||||
3. Will retry up to 3 times if FAILED
|
||||
4. Finally returns SUCCESS after max retries or on success
|
||||
|
|
@ -1,118 +0,0 @@
|
|||
# 🔍 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
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
# 🎯 Workflow Complete! But Data Shows "unknown"
|
||||
|
||||
## ✅ Current Status
|
||||
|
||||
The workflow is **working perfectly**:
|
||||
- All nodes execute
|
||||
- No errors
|
||||
- Completes successfully
|
||||
- Returns proper structure
|
||||
|
||||
## ❌ Issue: Data Shows "unknown"
|
||||
|
||||
**Current output:**
|
||||
```json
|
||||
{
|
||||
"status": "SUCCESS",
|
||||
"repo": "unknown", ← Should be: "gitadmin/test-repo"
|
||||
"branch": "main",
|
||||
"commit": "N/A", ← Should be: "abc123"
|
||||
"message": "Build completed successfully",
|
||||
"timestamp": "2025-12-01T19:02:06.631Z",
|
||||
"retry_count": 0,
|
||||
"emoji": "✅"
|
||||
}
|
||||
```
|
||||
|
||||
## 🔍 Root Cause
|
||||
|
||||
Node 7 tries to reference Node 2 data using:
|
||||
```javascript
|
||||
const repoInfo = $('Extract Repo Info').item.json;
|
||||
```
|
||||
|
||||
**The issue:**
|
||||
- `$('Node Name')` syntax doesn't work in n8n v2
|
||||
- Should use: `$node["Extract Repo Info"].json` or `$json`
|
||||
|
||||
## 🛠️ Fix: Update Node 7 to Use Current Item Data
|
||||
|
||||
In Node 7 **"Format Build Response"**, replace the code with:
|
||||
|
||||
```javascript
|
||||
// Use $json to get data from previous node (Node 6)
|
||||
const buildStatus = $json;
|
||||
|
||||
// The repo/branch/commit data comes from Node 2 "Extract Repo Info"
|
||||
// We need to get it from the workflow data flow
|
||||
const repoInfo = $node["Extract Repo Info"].json;
|
||||
|
||||
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: ($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;
|
||||
```
|
||||
|
||||
### Alternative (Simpler): Use Test Webhook
|
||||
|
||||
The easiest way to see the full data flow is to use the **Test Webhook** from n8n editor:
|
||||
1. Open workflow in n8n
|
||||
2. Click **"Execute Workflow"** button
|
||||
3. Send test payload
|
||||
4. Check each node's output - you'll see the actual data flowing through
|
||||
|
||||
### Alternative: Check Node Outputs
|
||||
|
||||
In n8n execution view:
|
||||
1. Click on **Node 2 "Extract Repo Info"**
|
||||
2. See output: Should show actual repo_full_name, commit_sha, etc.
|
||||
3. Click on **Node 6 "Check Build Status"**
|
||||
4. See output: Shows status and message
|
||||
5. Node 7 should read from both of these
|
||||
|
||||
## ✅ Expected After Fix
|
||||
|
||||
```json
|
||||
{
|
||||
"status": "SUCCESS",
|
||||
"repo": "gitadmin/test-repo", ← Actual repo name
|
||||
"branch": "main",
|
||||
"commit": "abc12345", ← First 8 chars of commit
|
||||
"message": "Build completed successfully",
|
||||
"timestamp": "2025-12-01T19:02:06.631Z",
|
||||
"retry_count": 0,
|
||||
"emoji": "✅"
|
||||
}
|
||||
```
|
||||
|
||||
## 🎯 Bottom Line
|
||||
|
||||
**Your workflow IS WORKING!** ✅
|
||||
The "unknown" values are just a data reference issue, not a functional problem.
|
||||
Loading…
Reference in New Issue