Skip to content

[copilot-finds] Bug: getNewEventSummary() logs "[undefined]" for unrecognized event types instead of "[UNKNOWN]" #247

@github-actions

Description

@github-actions

Problem

getNewEventSummary() in packages/durabletask-js/src/worker/index.ts (line 61) does not apply the ?? "UNKNOWN" fallback when enumValueToKey() returns undefined for an unrecognized event type in the single-event code path.

When a new event type is added to the protobuf definitions but not yet mapped in the JS enum, or when an unexpected event type value is received, the function produces the string [undefined] in log output instead of [UNKNOWN].

File: packages/durabletask-js/src/worker/index.ts, line 61

Root Cause

The single-event path uses enumValueToKey() directly without a nullish coalescing fallback:

const enumKey = enumValueToKey(pb.HistoryEvent.EventtypeCase, newEvents[0].getEventtypeCase());
return `[${enumKey}]`;  // produces "[undefined]" when enumKey is undefined

While the multi-event path on line 67 correctly uses ?? "UNKNOWN":

const eventTypeName = enumValueToKey(...) ?? "UNKNOWN";

And getActionSummary() also correctly uses ?? "UNKNOWN" in both its single-action (line 87) and multi-action (line 95) paths.

Proposed Fix

Add ?? "UNKNOWN" fallback to the single-event path to match the multi-event path and getActionSummary().

Additionally, add comprehensive unit tests for getNewEventSummary(), getActionSummary(), and getMethodNameForAction() which had zero test coverage.

Impact

Severity: Low — affects log output only, not runtime behavior.
Scenarios: Triggered when the sidecar sends an event type not yet mapped in the JS SDK's protobuf enum bindings, producing confusing [undefined] in worker logs instead of [UNKNOWN].

Metadata

Metadata

Assignees

No one assigned

    Labels

    copilot-findsFindings from daily automated code review agent

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions