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

+12 -11
View File
@@ -9,7 +9,8 @@ const path = require('path');
const fs = require('fs');
const helmet = require('helmet');
require('dotenv').config();
const { validateWebhookUrl, applyParams, evalCondition, conditionErrors, gotoErrors, calculateNextRun } = require('./lib/utils');
const { validateWebhookUrl, applyParams, evalCondition, conditionErrors, gotoErrors, calculateNextRun,
definitionErrors, resolveParams } = require('./lib/utils');
const { PAGES } = require('./lib/nav');
const { renderPage, renderError } = require('./lib/render');
const { upsertUser, makeAuthenticatePage, ssoIdentity, trustedProxies, ALLOWED_GROUPS } = require('./lib/pageauth');
@@ -799,7 +800,7 @@ function broadcast(data) {
// 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}`);
const parts = problems.slice(0, 5).map(p => `${p.where || 'step ' + p.step}: ${p.error}`);
if (problems.length > 5) parts.push(`and ${problems.length - 5} more`);
return 'Invalid workflow definition: ' + parts.join('; ');
}
@@ -1527,7 +1528,7 @@ app.post('/api/workflows', authenticateSSO, requireJSON, async (req, res) => {
if (!req.user.isAdmin) return res.status(403).json({ error: 'Admin only' });
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)];
const problems = [...definitionErrors(definition), ...conditionErrors(definition), ...gotoErrors(definition)];
if (problems.length) return res.status(400).json({ error: definitionError(problems), problems });
const webhookCheck = validateWebhookUrl(webhook_url);
@@ -1603,7 +1604,7 @@ app.post('/api/workers/heartbeat', async (req, res) => {
app.post('/api/executions', executionLimiter, authenticateSSO, requireJSON, async (req, res) => {
try {
const { workflow_id, params = {}, dry_run = false } = req.body;
const { workflow_id, params: requested = {}, dry_run = false } = req.body;
if (!workflow_id) return res.status(400).json({ error: 'workflow_id is required' });
const id = crypto.randomUUID();
@@ -1621,12 +1622,12 @@ app.post('/api/executions', executionLimiter, authenticateSSO, requireJSON, asyn
return res.status(500).json({ error: 'Workflow definition is corrupt' });
}
// Validate required params
const paramDefs = definition.params || [];
for (const pd of paramDefs) {
if (pd.required && !params[pd.name]) {
return res.status(400).json({ error: `Missing required parameter: ${pd.label || pd.name}` });
}
// Check every parameter before anything starts (#23): required ones present, each
// value valid for its type, defaults filled in. A bad value used to fail deep inside
// the run as "Unsafe value for workflow parameter".
const { params, errors: paramErrors } = resolveParams(definition.params, requested);
if (paramErrors.length) {
return res.status(400).json({ error: 'Invalid parameters: ' + paramErrors.join('; '), problems: paramErrors });
}
// Create execution record
@@ -1872,7 +1873,7 @@ app.put('/api/workflows/:id', authenticateSSO, requireJSON, async (req, res) =>
} catch {
return res.status(400).json({ error: 'Invalid JSON in definition' });
}
const problems = [...conditionErrors(defObj), ...gotoErrors(defObj)];
const problems = [...definitionErrors(defObj), ...conditionErrors(defObj), ...gotoErrors(defObj)];
if (problems.length) return res.status(400).json({ error: definitionError(problems), problems });
const [result] = await pool.query(