Workflow parameters: types, defaults, checked before a run (#23, #11)
CI / Test (jest) (pull_request) Successful in 26s
CI / Lint (eslint) (pull_request) Successful in 29s
CI / Security (npm audit) (pull_request) Successful in 13s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 1m36s
CI / Integration (api) (pull_request) Successful in 2m26s
CI / UI (playwright) (pull_request) Successful in 2m25s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
CI / UI screenshots (before/after) (pull_request) Successful in 2m3s

#23
- Parameters can be text (default), number (min, max), select
  (options), boolean, or worker, with a default. The Run dialog shows a
  matching field, the allowed characters for text, and the range for
  numbers; worker parameters choose from the connected workers.
- Values are checked before anything starts: in the dialog, naming the
  characters that are not allowed, and by the server (resolveParams),
  which answers 400 "Invalid parameters: ..." and creates no execution.
  A bad value used to fail mid-run as "Unsafe value for workflow
  parameter". Server errors now show in the dialog instead of a toast.

#11
- Saving a workflow checks its shape (definitionErrors): known step
  types and their required fields, unique ids, prompt routes that match
  options, route conditions, and parameter definitions. Unknown step
  types were silently skipped at run time.
- README documents the parameter types and the checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jaredandClaude Opus 5.5 committed 2026-11-23 18:11:49 -05:00
1 parent 7204c806df
commit a6d693c13e
8 files changed
+477 -39

No files matched your search

+28 -3
View File
@@ -98,9 +98,10 @@ test('parameters are substituted, and unsafe values are refused', async () => {
expect(ok.status).toBe('completed');
expect(outputs(ok)).toEqual(['host=db-01.lan']);
const bad = await waitForExecution(await start(wf, { params: { host: 'x; reboot' } }));
expect(bad.status).toBe('failed');
expect(outputs(bad)).toEqual([]);
// Refused up front (#23), rather than starting a run that fails mid-way.
const bad = await sso('POST', '/api/executions', { workflow_id: wf, params: { host: 'x; reboot' } });
expect(bad.status).toBe(400);
expect(bad.json.error).toMatch(/host may only contain/);
});
test('a dry run logs the commands without running them', async () => {
@@ -265,3 +266,27 @@ test('a rejected definition says what is wrong in the error itself (#25)', async
expect(res.json.error).toBe('Invalid workflow definition: step check: no step with id "nope"');
expect(res.json.problems).toHaveLength(1);
});
test('bad parameters are refused before a run is created (#23)', async () => {
const wf = await createWorkflow([{ id: 'e', type: 'execute', command: 'echo {{host}} {{count}}', targets: ['node-01'] }], {
params: [{ name: 'host', required: true }, { name: 'count', type: 'number', max: 5, default: '2' }],
});
const before = (await sso('GET', `/api/executions?search=${wf}&limit=5`)).json.total;
const r = await sso('POST', '/api/executions', { workflow_id: wf, params: { host: 'web 01', count: '9' } });
expect(r.status).toBe(400);
expect(r.json.error).toBe('Invalid parameters: host may only contain letters, digits and . _ : @ / -; count must be at most 5');
expect((await sso('GET', `/api/executions?search=${wf}&limit=5`)).json.total).toBe(before);
// Defaults fill in, and the run uses them.
const ex = await waitForExecution(await start(wf, { params: { host: 'web-01' } }));
expect(ex.status).toBe('completed');
expect(outputs(ex)).toEqual(['web-01 2']);
});
test('saving a definition with structural mistakes is refused (#11)', async () => {
const r = await sso('POST', '/api/workflows', { name: `bad ${unique()}`, definition: { steps: [
{ id: 'a', type: 'exec', command: 'true' },
] } });
expect(r.status).toBe(400);
expect(r.json.error).toBe('Invalid workflow definition: step a: unknown type "exec" (use execute, prompt, wait, parse, route)');
});