Say what is wrong with a rejected workflow definition (#25)
CI / Lint (eslint) (pull_request) Successful in 20s
CI / Test (jest) (pull_request) Successful in 22s
CI / Security (npm audit) (pull_request) Successful in 13s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 2m32s
CI / Integration (api) (pull_request) Successful in 3m24s
CI / UI screenshots (before/after) (pull_request) Successful in 6s
CI / UI (playwright) (pull_request) Successful in 1m53s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
CI / Lint (eslint) (pull_request) Successful in 20s
CI / Test (jest) (pull_request) Successful in 22s
CI / Security (npm audit) (pull_request) Successful in 13s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 2m32s
CI / Integration (api) (pull_request) Successful in 3m24s
CI / UI screenshots (before/after) (pull_request) Successful in 6s
CI / UI (playwright) (pull_request) Successful in 1m53s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
The server answered a bad goto or condition with "Invalid workflow definition" and put the details in a problems array, which the UI never shows (lt.api keeps only `error`). The error now names them, e.g. "Invalid workflow definition: step check: no step with id "notify"" (up to five, then "and N more"); problems stays for API clients. The rest of #25 was already fixed by the UI rewrite; regression tests now cover the server's reason in the form and Escape closing the Run dialog. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c5d2258f52
commit
e5d640dc1a
3 files changed
+43
-2
No files matched your search
@@ -795,6 +795,14 @@ function broadcast(data) {
|
||||
}
|
||||
|
||||
// Helper function to add log entry to execution (atomic: no read-modify-write race condition)
|
||||
// One readable message for the UI, which shows only `error` (#25):
|
||||
// "Invalid workflow definition: step check: no step with id "nope"".
|
||||
function definitionError(problems) {
|
||||
const parts = problems.slice(0, 5).map(p => `step ${p.step}: ${p.error}`);
|
||||
if (problems.length > 5) parts.push(`and ${problems.length - 5} more`);
|
||||
return 'Invalid workflow definition: ' + parts.join('; ');
|
||||
}
|
||||
|
||||
async function addExecutionLog(executionId, logEntry) {
|
||||
try {
|
||||
await pool.query(
|
||||
@@ -1519,7 +1527,7 @@ app.post('/api/workflows', authenticateSSO, requireJSON, async (req, res) => {
|
||||
const { name, description, definition, webhook_url } = req.body;
|
||||
if (!name || !definition) return res.status(400).json({ error: 'name and definition are required' });
|
||||
const problems = [...conditionErrors(definition), ...gotoErrors(definition)];
|
||||
if (problems.length) return res.status(400).json({ error: 'Invalid workflow definition', problems });
|
||||
if (problems.length) return res.status(400).json({ error: definitionError(problems), problems });
|
||||
|
||||
const webhookCheck = validateWebhookUrl(webhook_url);
|
||||
if (!webhookCheck.ok) return res.status(400).json({ error: webhookCheck.reason });
|
||||
@@ -1864,7 +1872,7 @@ app.put('/api/workflows/:id', authenticateSSO, requireJSON, async (req, res) =>
|
||||
return res.status(400).json({ error: 'Invalid JSON in definition' });
|
||||
}
|
||||
const problems = [...conditionErrors(defObj), ...gotoErrors(defObj)];
|
||||
if (problems.length) return res.status(400).json({ error: 'Invalid workflow definition', problems });
|
||||
if (problems.length) return res.status(400).json({ error: definitionError(problems), problems });
|
||||
|
||||
const [result] = await pool.query(
|
||||
'UPDATE workflows SET name=?, description=?, definition=?, webhook_url=?, updated_at=NOW() WHERE id=?',
|
||||
|
||||
Reference in new issue
Block a user