Skip to content

decide() DSL hardcodes value-param evaluator — JavaScript evaluator unreachable #24

Description

@nthmost-orkes

Summary

The decide() DSL method hardcodes evaluator_type = 'value-param' for all SWITCH tasks. Users who need a JavaScript expression evaluator must construct WorkflowTask manually — there is no way to express this through the builder.

Tested against: Conductor OSS 3.32.0-rc.9

Root Cause

# lib/conductor/workflow/dsl/task_ref.rb:110-111
def apply_switch_fields(wf_task)
  wf_task.evaluator_type = 'value-param'  # hardcoded — cannot be 'javascript'
  ...
end

workflow_builder.rb#add_switch_task passes no evaluator_type in options; apply_switch_fields ignores any such option and hardcodes 'value-param'.

The server supports two evaluator types for SWITCH:

  • "value-param" — compares inputParameters.switchCaseValue against case strings
  • "javascript" — evaluates a full JavaScript expression and matches the result against cases

Impact

Users who want to branch on a computed value (not a simple reference comparison) cannot use the decide DSL. They must construct the task definition raw.

Fix

Thread evaluator_type through from decide():

# workflow_builder.rb
def decide(expression, evaluator_type: 'value-param', &block)
  builder = SwitchBuilder.new(resolve_value(expression), self)
  builder.instance_eval(&block)
  add_switch_task(builder, evaluator_type: evaluator_type)
end

def add_switch_task(builder, evaluator_type: 'value-param')
  task_ref = TaskRef.new(
    ...
    options: {
      expression: builder.expression,
      evaluator_type: evaluator_type,   # ← pass through
      decision_cases: builder.cases,
      default_case: builder.default
    }
  )
  ...
end

# task_ref.rb
def apply_switch_fields(wf_task)
  wf_task.evaluator_type = @options[:evaluator_type] || 'value-param'
  ...
end

Related: JavaScript SDK #139 — same gap.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions