Skip to content

switchTask() hardcodes value-param evaluator; JavaScript evaluator unreachable via builder #139

Description

@nthmost-orkes

Summary

switchTask() hardcodes evaluatorType: "value-param". The SwitchTaskDef interface
and the server both support "javascript" as an evaluator type, but there is no way to
use a JavaScript expression for SWITCH via the builder API.

Server baseline

Conductor 3.32.0-rc.9

Evidence

// switch.ts
export const switchTask = (
  taskReferenceName: string,
  expression: string,
  ...
): SwitchTaskDef => ({
  evaluatorType: "value-param",     // hardcoded — no parameter to change this
  inputParameters: { switchCaseValue: expression },
  expression: "switchCaseValue",
  ...
});

But SwitchTaskDef is typed as:

evaluatorType: "value-param" | "javascript";   // server supports both

Users who need a JavaScript evaluator (arbitrary expression like
$.input.age >= 18 ? 'adult' : 'minor') must construct SwitchTaskDef manually,
bypassing the builder entirely.

Proposed fix

Add an optional evaluatorType parameter:

export const switchTask = (
  taskReferenceName: string,
  expression: string,
  decisionCases: Record<string, TaskDefTypes[]> = {},
  defaultCase: TaskDefTypes[] = [],
  evaluatorType: "value-param" | "javascript" = "value-param",
  optional?: boolean
): SwitchTaskDef => ({
  name: taskReferenceName,
  taskReferenceName,
  decisionCases,
  evaluatorType,
  inputParameters: evaluatorType === "value-param"
    ? { switchCaseValue: expression }
    : {},
  expression: evaluatorType === "value-param" ? "switchCaseValue" : expression,
  defaultCase,
  type: TaskType.SWITCH,
  optional,
});

Related

Discovered during systematic SDK audit against Conductor OSS 3.32.0-rc.9.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions