Merge pull request 'Say what is wrong with a rejected workflow definition' (#77) from workflow-error-details into main
CI / UI screenshots (before/after) (push) Skipped
CI / Test (jest) (push) Successful in 22s
CI / Lint (eslint) (push) Successful in 23s
CI / Security (npm audit) (push) Successful in 19s
CI / Scan (secrets, workflows, shell) (push) Successful in 2m31s
CI / Integration (api) (push) Successful in 3m33s
CI / UI (playwright) (push) Successful in 2m10s
CI / Deploy (push) Successful in 21s
CI / Deploy worker (push) Successful in 6s
CI / Notify (push) Successful in 3s
CI / UI screenshots (before/after) (push) Skipped
CI / Test (jest) (push) Successful in 22s
CI / Lint (eslint) (push) Successful in 23s
CI / Security (npm audit) (push) Successful in 19s
CI / Scan (secrets, workflows, shell) (push) Successful in 2m31s
CI / Integration (api) (push) Successful in 3m33s
CI / UI (playwright) (push) Successful in 2m10s
CI / Deploy (push) Successful in 21s
CI / Deploy worker (push) Successful in 6s
CI / Notify (push) Successful in 3s
This commit was merged in pull request #77.
This commit is contained in:
commit
424309e3c3
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=?',
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
@@ -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'] },
|
||||
|
||||
Reference in new issue
Block a user