Skip to content

Commit

Permalink
handle undefined condition for trigger edges
Browse files Browse the repository at this point in the history
  • Loading branch information
taylordowns2000 committed Dec 26, 2023
1 parent 3a2d8c5 commit 003a3ad
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/ws-worker/src/util/convert-attempt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ const mapEdgeCondition = (edge: Edge) => {
return condition;
};

const mapTriggerEdgeCondition = (edge: Edge) => {
const { condition } = edge;
// This handles cron triggers with undefined conditions and the 'always' string.
if (condition === undefined || condition === 'always') return true;
// Otherwise, we will return the condition and assume it's a valid JS expression.
return condition;
};

export default (
attempt: Attempt
): { plan: ExecutionPlan; options: AttemptOptions } => {
Expand Down Expand Up @@ -63,8 +71,7 @@ export default (
nodes[id].next = connectedEdges.reduce((obj, edge) => {
if (edge.enabled !== false) {
// @ts-ignore
obj[edge.target_job_id] =
edge.condition == 'always' ? true : edge.condition;
obj[edge.target_job_id] = mapTriggerEdgeCondition(edge);
}
return obj;
}, {});
Expand Down

0 comments on commit 003a3ad

Please sign in to comment.