Skip to content

Fix falsy values (0, empty string, false, null) silently dropped during serialization#138

Merged
torosent merged 5 commits intomainfrom
copilot-finds/bug/fix-falsy-input-serialization
Mar 6, 2026
Merged

Fix falsy values (0, empty string, false, null) silently dropped during serialization#138
torosent merged 5 commits intomainfrom
copilot-finds/bug/fix-falsy-input-serialization

Conversation

@YunchuWang
Copy link
Member

@YunchuWang YunchuWang commented Mar 5, 2026

Summary

Fixes #127

Falsy JavaScript values (0, "", false, null) were silently dropped when passed as activity input, sub-orchestration input, orchestration return values, and continueAsNew input. This happened because the serialization code used truthy checks (if (input)) instead of explicit undefined checks (if (input !== undefined)).

Changes

runtime-orchestration-context.ts:

  1. callActivityinput ? JSON.stringify(input)input !== undefined ? JSON.stringify(input)
  2. callSubOrchestrator — same pattern
  3. setCompleteif (result)if (result !== undefined)
  4. getActions (continue-as-new input)this._newInput ?this._newInput !== undefined ?
  5. getActions (carryover events)eventValue ?eventValue !== undefined ?

Tests

14 new unit tests in falsy-input-serialization.spec.ts:

  • 4 tests for callActivity with each falsy value (0, "", false, null)
  • 4 tests for callSubOrchestrator with each falsy value
  • 4 tests for orchestration completion results with each falsy value
  • 1 test for continueAsNew with zero input
  • 1 test confirming undefined inputs are still correctly treated as "no input"

All existing unit tests continue to pass.

…n, and completion paths

Replace truthy checks with explicit !== undefined checks when serializing
inputs and results in RuntimeOrchestrationContext. Previously, falsy values
like 0, empty string, false, and null were silently dropped because the
code used 'if (input)' instead of 'if (input !== undefined)'.

Affected paths:
- callActivity: input serialization
- callSubOrchestrator: input serialization
- setComplete: orchestration result serialization
- getActions (continue-as-new): newInput and carryover event serialization

Note: sendEvent, signalEntity, and callEntity already used the correct
!== undefined check and were not affected.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 5, 2026 22:04
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes serialization so falsy JavaScript values (0, "", false, null) are no longer silently dropped when encoding orchestration/activity inputs and outputs.

Changes:

  • Replaced truthy checks with explicit !== undefined checks across runtime serialization paths.
  • Added a new Jest spec file covering activity input, sub-orchestrator input, orchestration results, and continueAsNew behavior for falsy values.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/durabletask-js/src/worker/runtime-orchestration-context.ts Ensures serialization includes falsy values by checking !== undefined before JSON encoding.
packages/durabletask-js/test/falsy-input-serialization.spec.ts Adds unit tests to prevent regressions for falsy-value serialization across multiple APIs.

YunchuWang and others added 2 commits March 5, 2026 14:12
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Fix activity-executor.ts: activityOutput ?  activityOutput !== undefined ?
  (same truthy bug as the input paths, causing 0, '', false, null to be dropped
  from activity return values)
- Add 5 unit tests for activity output falsy values
- Add 9 e2e tests verifying falsy value round-trips against real DTS:
  - 4 activity round-trips (0, '', false, null)
  - 1 sub-orchestration round-trip (0)
  - 3 orchestration results (0, false, '')
  - 1 continueAsNew with zero input
@torosent torosent merged commit 05ab1da into main Mar 6, 2026
28 checks passed
@torosent torosent deleted the copilot-finds/bug/fix-falsy-input-serialization branch March 6, 2026 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sample-verification-added PR has been verified with a sample application

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[copilot-finds] Bug: Falsy values (0, "", false, null) silently dropped when serializing inputs and results

3 participants