NeahNew/MISSION_CREATION_CALLBACK_MISSING.md
2026-01-09 11:19:32 +01:00

5.4 KiB

Mission Creation - N8N Callback Not Being Called

🔍 Problem Analysis

From your logs, I can see:

What's Working

  1. Mission created in database

    Mission created successfully { missionId: '5815440f-af1c-4c6a-bfa6-92f06058f9c8', name: 'bbc' }
    
  2. N8N workflow triggered

    Starting N8N workflow
    POST /mission-created 200 in 851ms  ← This is N8N RECEIVING the webhook
    
  3. N8N workflow completes

    N8N workflow result { success: true, hasError: false }
    

What's Missing

NO log from /api/missions/mission-created endpoint!

Expected log (but NOT present):

Mission Created Webhook Received  ← This should appear but doesn't

This means: N8N workflow is NOT calling /api/missions/mission-created to save the integration IDs.


🔍 Root Cause

The N8N workflow completes successfully, but the "Save Mission To API" node is either:

  1. Not configured correctly (wrong URL)
  2. Not executing (node disabled or failing silently)
  3. Failing but not blocking the workflow (continueOnFail: true)

Solution: Verify N8N "Save Mission To API" Node

Step 1: Check N8N Execution Logs

  1. Go to N8N → Executions
  2. Find the latest mission creation execution
  3. Click on it to see the execution details
  4. Look for "Save Mission To API" node:
    • Is it executed?
    • What's the status (success/error)?
    • What URL is it calling?
    • What's the response?

Step 2: Verify Node Configuration

In N8N workflow, check "Save Mission To API" node:

  1. URL should be:

    {{ $node['Process Mission Data'].json.config.MISSION_API_URL }}/api/missions/mission-created
    

    NOT:

    {{ $node['Process Mission Data'].json.config.MISSION_API_URL + '/mission-created' }}
    
  2. Method: POST

  3. Headers:

    • Content-Type: application/json
    • x-api-key: {{ $node['Process Mission Data'].json.config.N8N_API_KEY }}
  4. Body Parameters should include:

    • missionId: {{ $node['Process Mission Data'].json.missionId }}
    • gitRepoUrl: {{ $node['Combine Results'].json.gitRepo?.html_url || '' }}
    • leantimeProjectId: {{ $node['Combine Results'].json.leantimeProject?.result?.[0] || '' }}
    • documentationCollectionId: {{ $node['Combine Results'].json.docCollection?.data?.id || '' }}
    • rocketchatChannelId: {{ $node['Combine Results'].json.rocketChatChannel?.channel?._id || '' }}
    • name: {{ $node['Process Mission Data'].json.missionProcessed.name }}
    • creatorId: {{ $node['Process Mission Data'].json.creatorId }}
  5. Node Options:

    • Should NOT have continueOnFail: true (or it will fail silently)
    • Should be set to fail the workflow if it fails

Step 3: Test the Endpoint Manually

Test if the endpoint is accessible:

curl -X POST https://hub.slm-lab.net/api/missions/mission-created \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_N8N_API_KEY" \
  -d '{
    "missionId": "5815440f-af1c-4c6a-bfa6-92f06058f9c8",
    "name": "bbc",
    "creatorId": "203cbc91-61ab-47a2-95d2-b5e1159327d7",
    "gitRepoUrl": "https://gite.slm-lab.net/alma/test",
    "leantimeProjectId": "123",
    "documentationCollectionId": "collection-456",
    "rocketchatChannelId": "channel-789"
  }'

Expected: 200 OK with updated mission data

If 500 error: N8N_API_KEY is not set in environment

If 404 error: Wrong URL

If 401 error: Wrong API key


🔧 Common Issues

Issue 1: Wrong URL in N8N

Symptom: Node fails with 404 error

Fix: Change URL from:

{{ MISSION_API_URL + '/mission-created' }}

To:

{{ MISSION_API_URL }}/api/missions/mission-created

Issue 2: Missing missionId in Body

Symptom: Endpoint can't find mission (404)

Fix: Add missionId parameter to body:

  • Name: missionId
  • Value: {{ $node['Process Mission Data'].json.missionId }}

Issue 3: continueOnFail: true

Symptom: Node fails but workflow continues (no error visible)

Fix: Remove continueOnFail: true or set to false

Issue 4: N8N_API_KEY Not Set

Symptom: Endpoint returns 500 "Server configuration error"

Fix: Add N8N_API_KEY to environment variables


📋 Debugging Checklist

  • Check N8N execution logs for "Save Mission To API" node
  • Verify node URL is correct: {{ MISSION_API_URL }}/api/missions/mission-created
  • Verify node includes missionId in body
  • Verify node includes x-api-key header
  • Check if node has continueOnFail: true (should be false)
  • Test endpoint manually with curl
  • Verify N8N_API_KEY is set in environment
  • Check server logs for any calls to /api/missions/mission-created

🎯 Expected Flow

1. Mission created in database ✅
2. N8N workflow triggered ✅
3. N8N creates integrations ✅
4. N8N calls /api/missions/mission-created ⚠️ (MISSING)
5. IDs saved to database ⚠️ (NOT HAPPENING)
6. Mission has integration IDs ⚠️ (ALL NULL)

📝 Next Steps

  1. Check N8N execution logs to see what "Save Mission To API" node is doing
  2. Verify node configuration matches the requirements above
  3. Test endpoint manually to ensure it's accessible
  4. Fix any configuration issues found
  5. Re-test mission creation and verify IDs are saved

Document Created: $(date) Status: N8N workflow completes but callback to save IDs is not being called