Merge pull request 'Fix abort, missing goto, offline schedules and the cron 500' (#66) from fix-known-bugs into main
CI / UI screenshots (before/after) (push) Skipped
CI / Lint (eslint) (push) Successful in 1m41s
CI / Security (npm audit) (push) Successful in 1m0s
CI / Test (jest) (push) Failing after 1m5s
CI / Scan (secrets, workflows, shell) (push) Successful in 4m25s
CI / Integration (api) (push) Failing after 4m31s
CI / UI (playwright) (push) Successful in 5m23s
CI / Deploy (push) Skipped
CI / Deploy worker (push) Skipped
CI / Notify (push) Successful in 4s

This commit was merged in pull request #66.
This commit is contained in:
jared committed 2026-11-23 00:26:30 -05:00
commit 1a031515e7
5 files changed
+166 -32

No files matched your search

+28 -1
View File
@@ -82,6 +82,33 @@ function conditionErrors(definition) {
return problems;
}
/**
* Every jump in a workflow definition to a step id that doesn't exist (#20), as
* [{ step, goto, error }]. 'end' and '__end__' finish the workflow and are always valid.
*/
function gotoErrors(definition) {
let def = definition;
if (typeof def === 'string') {
try { def = JSON.parse(def); } catch { return []; }
}
const steps = (def && Array.isArray(def.steps)) ? def.steps : [];
const ids = new Set(steps.map(st => st && st.id).filter(Boolean));
const ok = target => target === 'end' || target === '__end__' || ids.has(target);
const problems = [];
steps.forEach((step, i) => {
if (!step) return;
const label = step.id || step.name || `step ${i + 1}`;
const targets = [];
if (step.goto) targets.push(step.goto);
for (const c of (Array.isArray(step.conditions) ? step.conditions : [])) if (c && c.goto) targets.push(c.goto);
if (step.routes && typeof step.routes === 'object') targets.push(...Object.values(step.routes));
for (const t of targets) {
if (typeof t !== 'string' || !ok(t)) problems.push({ step: label, goto: t, error: `no step with id ${JSON.stringify(t)}` });
}
});
return problems;
}
/**
* Calculate the next run date for a scheduled command.
*/
@@ -112,4 +139,4 @@ function calculateNextRun(scheduleType, scheduleValue) {
throw new Error(`Unknown schedule type: ${scheduleType}`);
}
module.exports = { validateWebhookUrl, applyParams, evalCondition, conditionErrors, calculateNextRun };
module.exports = { validateWebhookUrl, applyParams, evalCondition, conditionErrors, gotoErrors, calculateNextRun };