4.3 KiB
4.3 KiB
🔧 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
- Go to: https://n8n.oky.sh
- Open: "Gitea → OpenHands Enhanced CI/CD" workflow
- You should see all the nodes in a flow
Step 2: Fix Node 2 - "Extract Repo Info"
- Click on Node 2 (the blue code node)
- Find the JavaScript code (should be in a text area)
- REPLACE THE ENTIRE CODE with this:
// 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
};
- Click "Update" or Save
Step 3: Fix Node 7 - "Format Build Response"
- Click on Node 7 (later in the flow)
- Find the JavaScript code
- REPLACE THE ENTIRE CODE with this:
// 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;
- Click "Update" or Save
Step 4: Save the Entire Workflow
- Click "Save" (top-right of the workflow editor)
- Make sure the workflow is ACTIVE (toggle switch should be green/blue)
Step 5: Test It
- Click "Execute Workflow" button (top-right)
- Use this test data:
{
"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"}
}
- Click "Execute Workflow"
Step 6: Check the Result
Look at Node 7 "Format Build Response" output. You should see:
{
"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
- In n8n, go to the workflow editor
- Click "..." menu (three dots, top-right)
- Select "Export"
- Download the JSON file
- 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!