Skip to content

[Bug] ActivityInterface empty default prefix causes activity type name collision #722

@koren88

Description

@koren88

What are you really trying to do?

Register multiple activity classes on the same worker without activity type name collisions.

Describe the bug

ActivityInterface::$prefix defaults to an empty string, meaning activity type names are derived from method names alone. This makes collisions inevitable when multiple activity classes share method names — and the wrong implementation gets executed silently with no error.

Minimal Reproduction

#[ActivityInterface] // prefix = ''
class ActivityA {
    #[ActivityMethod]
    public function doWork(): string { return 'ActivityA'; }
}

#[ActivityInterface] // prefix = ''
class ActivityB {
    #[ActivityMethod]
    public function doWork(): string { return 'ActivityB'; }
}

Both register as activity type doWork. Calling ActivityA::doWork() may execute ActivityB::doWork() instead.

Environment/Versions

  • Temporal PHP SDK 2.14.0
  • Docker

Additional context

The workaround is either manually setting a prefix: #[ActivityInterface(prefix: 'classA.')] or explicitly naming every method: #[ActivityMethod(name: 'classA.doWork')].

Both are easy to forget and not prominently documented as required practice.

Suggested fix: Default prefix to the short class name (e.g. ActivityA.) instead of an empty string, similar to the Java SDK behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions