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

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:
jaredandClaude Opus 5.5 committed 2026-11-23 14:00:25 -05:00
1 parent c5d2258f52
commit e5d640dc1a
3 files changed
+43 -2

No files matched your search

+10 -2
View File
@@ -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=?',
+9
View File
@@ -256,3 +256,12 @@ test('a failure on one target fails the step, after every target has reported (#
expect(outputs(ex).filter(o => o === 'ok')).toHaveLength(2);
expect(outputs(ex)).not.toContain('should-not-run');
});
test('a rejected definition says what is wrong in the error itself (#25)', async () => {
const res = await sso('POST', '/api/workflows', { name: `bad-goto-${unique()}`, definition: { steps: [
{ id: 'check', type: 'execute', command: 'true', goto: 'nope' },
] } });
expect(res.status).toBe(400);
expect(res.json.error).toBe('Invalid workflow definition: step check: no step with id "nope"');
expect(res.json.problems).toHaveLength(1);
});
+24
View File
@@ -43,6 +43,30 @@ test('an invalid workflow definition is rejected with a message', async ({ page,
expect(problems).toEqual([]); // rejected in the browser, so no failed request either
});
test('a definition the server rejects shows the server\'s reason (#25)', async ({ page, problems }) => {
await page.goto('/workflows');
await page.getByRole('button', { name: '+ Create Workflow' }).click();
await page.locator('#wf-create-name').fill(`Bad goto ${Date.now()}`);
await page.locator('#wf-create-definition').fill(JSON.stringify({ steps: [
{ id: 'check', type: 'execute', command: 'true', goto: 'nope' },
] }));
await page.locator('#wf-create-form').getByRole('button', { name: 'Create' }).click();
await expect(page.locator('#wf-create-error')).toContainText('no step with id "nope"');
// The 400 (and the browser's console line for it) is the point of this test.
expect(problems.every(p => /400/.test(p))).toBe(true);
problems.length = 0;
});
test('Escape closes the Run dialog (#25)', async ({ page, request }) => {
const name = `UI esc ${Date.now()}`;
await request.post('/api/workflows', { data: { name, definition: { steps: [{ id: 'a', type: 'execute', command: 'true' }] } } });
await page.goto('/workflows');
await page.locator('#wf-list tr', { hasText: name }).getByRole('button', { name: 'Execute' }).click();
await expect(page.locator('#wf-run-modal')).toBeVisible();
await page.keyboard.press('Escape');
await expect(page.locator('#wf-run-modal')).toBeHidden();
});
test('a run waiting on a prompt shows as waiting, and the Waiting filter finds it (#3)', async ({ page, request }) => {
const created = await request.post('/api/workflows', { data: { name: `UI wait ${Date.now()}`, definition: { steps: [
{ id: 'ask', type: 'prompt', message: 'Proceed?', options: ['Yes'] },