Skip to content

fix: avoid wildcard names for anonymous generator functions#262

Merged
YunchuWang merged 4 commits into
mainfrom
copilot-finds/bug/fix-getfunctionname-generator-star
Jun 12, 2026
Merged

fix: avoid wildcard names for anonymous generator functions#262
YunchuWang merged 4 commits into
mainfrom
copilot-finds/bug/fix-getfunctionname-generator-star

Conversation

@YunchuWang

Copy link
Copy Markdown
Member

Summary

Fixes #245

Copilot AI review requested due to automatic review settings June 11, 2026 20:53
Fix _getFunctionName fallback parser to handle generator functions and
arrow functions correctly:

- Return "" for arrow functions (no "function" keyword to parse)
- Skip "*" after "function" keyword in generator functions
- Guard against missing "(" in malformed input

Previously, anonymous generator functions registered under name "*",
silently passing validation but never matching scheduled orchestrations.

Update test helper in orchestration_executor.spec.ts to handle anonymous
inline orchestrators by falling back to addNamedOrchestrator.

Fixes #245

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@YunchuWang YunchuWang force-pushed the copilot-finds/bug/fix-getfunctionname-generator-star branch from a17812f to a94b9c0 Compare June 11, 2026 20:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes function-name auto-detection in the worker Registry to prevent anonymous generator functions from being registered under the invalid wildcard name "*", addressing issue #245. This improves reliability of orchestrator/activity registration by ensuring truly-anonymous functions fail fast with the existing “non-empty name required” validation.

Changes:

  • Hardened Registry._getFunctionName() parsing to avoid returning "*" for anonymous generator functions and to return "" for arrow functions.
  • Added unit tests covering named/anonymous functions, generators, async generators, and arrow functions for _getFunctionName().
  • Updated the orchestration executor test helper to provide a default orchestrator name when tests use anonymous inline orchestrators.

Reviewed changes

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

File Description
packages/durabletask-js/src/worker/registry.ts Updates function-name fallback logic to avoid wildcard/garbage names for anonymous functions.
packages/durabletask-js/test/registry.spec.ts Adds targeted tests for _getFunctionName() and validates addOrchestrator/addActivity behavior for anonymous functions.
packages/durabletask-js/test/orchestration_executor.spec.ts Adjusts a shared test helper to handle anonymous orchestrators by registering a default name.

Comment thread packages/durabletask-js/src/worker/registry.ts Outdated
Comment thread packages/durabletask-js/test/orchestration_executor.spec.ts
Constrain Registry._getFunctionName() fallback parsing to leading function declarations so arrow function bodies containing nested functions do not produce bogus names.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread packages/durabletask-js/src/worker/registry.ts Fixed
YunchuWang and others added 2 commits June 11, 2026 14:56
Replace the fallback parser regex with linear string parsing so function name detection only considers leading function signatures and avoids CodeQL polynomial-regex findings.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Only fall back to a default orchestrator name when addOrchestrator fails with the expected missing-name validation error; rethrow unexpected registration failures.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@YunchuWang YunchuWang merged commit 8e8d6dc into main Jun 12, 2026
28 checks passed
@YunchuWang YunchuWang deleted the copilot-finds/bug/fix-getfunctionname-generator-star branch June 12, 2026 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[copilot-finds] Bug: Registry._getFunctionName() returns '*' for anonymous generator functions, causing silent registration failure

5 participants