-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Problem
Falsy JavaScript values (0, "", false, null) are silently dropped when passed as:
- Activity input via
callActivity(activity, 0) - Sub-orchestration input via
callSubOrchestrator(orch, 0) - Orchestration return values (e.g.,
return 0) continueAsNewinput and carryover event values
This happens because the serialization code uses truthy checks (if (input)) instead of explicit undefined checks (if (input !== undefined)). For example, in runtime-orchestration-context.ts:
// Before (broken): drops 0, "", false, null
const encodedInput = input ? JSON.stringify(input) : undefined;
// After (fixed): only skips undefined
const encodedInput = input !== undefined ? JSON.stringify(input) : undefined;Interestingly, other methods in the same file (sendEvent, signalEntity, callEntity) already use the correct !== undefined pattern, making this an inconsistency within the codebase.
Root Cause
JavaScript truthy evaluation treats 0, "", false, and null as falsy. The affected code paths use if (value) to check whether to serialize, which incorrectly skips these valid values.
Fix Available
Branch copilot-finds/bug/fix-falsy-input-serialization contains the complete fix with 14 new unit tests.
Changes in runtime-orchestration-context.ts:
callActivity—input ? JSON.stringify(input)→input !== undefined ? JSON.stringify(input)callSubOrchestrator— same patternsetComplete—if (result)→if (result !== undefined)getActions(continue-as-new input) —this._newInput ?→this._newInput !== undefined ?getActions(carryover events) —eventValue ?→eventValue !== undefined ?
Tests added in falsy-input-serialization.spec.ts:
- 4 tests for
callActivitywith each falsy value (0, "", false, null) - 4 tests for
callSubOrchestratorwith each falsy value - 4 tests for orchestration completion results with each falsy value
- 1 test for
continueAsNewwith zero input - 1 test confirming undefined inputs are still correctly treated as "no input"
All 730 existing unit tests continue to pass. A PR could not be created automatically due to GitHub Actions permissions — the fix branch is ready for manual PR creation.