Add detailed logging to workflow creation endpoint
This will help diagnose the 'Cannot read properties of undefined' error by logging each step of the workflow creation process. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -692,14 +692,23 @@ app.post('/api/workflows', authenticateSSO, async (req, res) => {
|
|||||||
const { name, description, definition } = req.body;
|
const { name, description, definition } = req.body;
|
||||||
const id = generateUUID();
|
const id = generateUUID();
|
||||||
|
|
||||||
|
console.log('[Workflow] Creating workflow:', name);
|
||||||
|
console.log('[Workflow] Definition:', JSON.stringify(definition, null, 2));
|
||||||
|
|
||||||
await pool.query(
|
await pool.query(
|
||||||
'INSERT INTO workflows (id, name, description, definition, created_by) VALUES (?, ?, ?, ?, ?)',
|
'INSERT INTO workflows (id, name, description, definition, created_by) VALUES (?, ?, ?, ?, ?)',
|
||||||
[id, name, description, JSON.stringify(definition), req.user.username]
|
[id, name, description, JSON.stringify(definition), req.user.username]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log('[Workflow] Successfully inserted workflow:', id);
|
||||||
|
|
||||||
res.json({ id, name, description, definition });
|
res.json({ id, name, description, definition });
|
||||||
|
|
||||||
|
console.log('[Workflow] Broadcasting workflow_created');
|
||||||
broadcast({ type: 'workflow_created', workflow_id: id });
|
broadcast({ type: 'workflow_created', workflow_id: id });
|
||||||
|
console.log('[Workflow] Broadcast complete');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.error('[Workflow] Error creating workflow:', error);
|
||||||
res.status(500).json({ error: error.message });
|
res.status(500).json({ error: error.message });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user