Skip to content

[copilot-finds] Bug: convertEntityMetadata() defaults missing lastModifiedTime to current time instead of epoch #240

@github-actions

Description

@github-actions

Problem

In packages/durabletask-js/src/client/client.ts, the convertEntityMetadata() method (line 1208) uses new Date() (current time) as the default when the protobuf lastModifiedTime field is missing:

const lastModifiedTime = protoMetadata.getLastmodifiedtime()?.toDate() ?? new Date();

This is inconsistent with _createOrchestrationStateFromProto() in the same file (lines 1243-1244), which correctly uses new Date(0) (Unix epoch) for missing timestamps:

const createdAt = createdTimestamp ? createdTimestamp.toDate() : new Date(0);
const lastUpdatedAt = lastUpdatedTimestamp ? lastUpdatedTimestamp.toDate() : new Date(0);

Root Cause

The fallback value was written as new Date() instead of new Date(0). This appears to be an oversight — every other missing-timestamp default in the same file uses epoch.

Proposed Fix

Change new Date() to new Date(0) on line 1208 to match the established pattern.

Impact

Severity: Medium — When a protobuf EntityMetadata response has no lastModifiedTime set, callers receive the current wall-clock time instead of a sentinel epoch value. This makes it impossible to distinguish between "entity was just modified" and "entity has no known modification time", potentially causing incorrect display, sorting, or filtering logic in consuming code.

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