conductor-oss / conductor-oss/javascript-sdk

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

Open Beginner friendly
#139 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
58
Forks
20
Avg merge
1d 13h
Merged PRs (30d)
7

Description

## 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

```typescript
// 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:
```typescript
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:

```typescript
export const switchTask = (
taskReferenceName: string,
expression: string,
decisionCases: Record = {},
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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in switch.ts at the switchTask() builder and compare its current return shape with the SwitchTaskDef evaluatorType union. Verify the default value-param path remains unchanged and that selecting javascript produces the expression and inputParameters shape described in the issue. Done means the builder can create both supported evaluator types without requiring manual SwitchTaskDef construction.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.