Skip to content

[copilot-finds] Improve: DurableTaskAzureManagedWorkerBuilder missing addEntity/addNamedEntity methods #239

@github-actions

Description

@github-actions

Problem

DurableTaskAzureManagedWorkerBuilder provides fluent builder methods for registering orchestrators (addOrchestrator, addNamedOrchestrator) and activities (addActivity, addNamedActivity), but has no corresponding methods for entity registration.

Users who need entities must call worker.addEntity() or worker.addNamedEntity() directly on the TaskHubGrpcWorker returned by build(), breaking the fluent builder pattern:

// Current workaround (inconsistent with orchestrator/activity registration)
const worker = new DurableTaskAzureManagedWorkerBuilder()
  .endpoint(endpoint, taskHub, null)
  .addNamedOrchestrator('myOrch', orchestrator)
  .addNamedActivity('myActivity', activity)
  .build();
worker.addNamedEntity('CounterEntity', () => new CounterEntity()); // Must break the chain

This gap is visible in the e2e entity tests (test/e2e-azuremanaged/entity.spec.ts), which all use the direct worker method instead of the builder.

File: packages/durabletask-js-azuremanaged/src/worker-builder.ts

Root Cause

Entity support was added to the core TaskHubGrpcWorker but the Azure managed builder wrapper was not updated to expose the same registration methods.

Proposed Fix

Add addEntity(factory) and addNamedEntity(name, factory) methods to DurableTaskAzureManagedWorkerBuilder, following the exact same pattern used for orchestrators and activities. Store entity factories during configuration and register them on the worker during build().

Impact

Severity: Low — functional workaround exists.
Affected scenarios: Any Azure managed Durable Task user who wants to register entities through the builder pattern. The builder's own useWorkItemFilters documentation (line 228) already references entities, suggesting they were intended to be registerable through the builder.

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