Skip to content

[copilot-finds] Bug: client.getEntities() does not normalize instanceIdStartsWith prefix, causing silent query failures #222

@github-actions

Description

@github-actions

Problem

TaskHubGrpcClient.getEntities() passes the instanceIdStartsWith query parameter directly to the gRPC backend without normalizing it. Entity names are stored in lowercase with the @name@key format (e.g., @counter@my-key), but the client sends the raw user-provided prefix.

File: packages/durabletask-js/src/client/client.ts, lines 1106-1110

This means:

  • getEntities({ instanceIdStartsWith: "Counter" }) sends "Counter" instead of "@counter"
  • getEntities({ instanceIdStartsWith: "Counter@User" }) sends "Counter@User" instead of "@counter@User"

Queries with mixed-case names or missing @ prefix silently return zero results.

Root Cause

The normalizeInstanceIdPrefix() utility function was specifically created to handle this normalization (adding @ prefix, lowercasing the name portion while preserving key case). It is well-tested in entity-query.spec.ts and exported from the package. However, the getEntities() method in client.ts does not call it.

The createEntityQuery() helper that wraps this normalization is also exported for user convenience, but the client itself never applies it internally.

Proposed Fix

Import normalizeInstanceIdPrefix and apply it to query.instanceIdStartsWith before sending the query to the backend. This is a one-line change that connects the existing normalization utility to the client method that needs it.

Impact

Severity: Medium — Entity queries with non-normalized prefixes return empty results with no error, making it a silent data loss issue. Users who happen to pass already-normalized prefixes (e.g., "@counter@") are not affected.

Affected scenarios: Any call to getEntities() where the instanceIdStartsWith value uses mixed-case entity names or omits the leading @.

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