Skip to content

fix: Reject duplicate handler names at registration - #234

Open
RaphaelFakhri wants to merge 1 commit into
restatedev:mainfrom
RaphaelFakhri:fix/duplicate-handler-name
Open

RaphaelFakhri wants to merge 1 commit into
restatedev:mainfrom
RaphaelFakhri:fix/duplicate-handler-name

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

Reject duplicate handler names at registration

Fixes #10

Registering two handlers with the same name on a Service, VirtualObject or Workflow silently replaced the first handler with the second. The decorator now raises a ValueError when a handler with the same name is already registered, which surfaces the mistake when the module is imported.

The error message follows the one Endpoint.bind raises for duplicate service names, for example Handler greet already exists in Greeter.

Testing

tests/duplicate_handlers.py covers Service, VirtualObject and Workflow, including a workflow main handler and a shared handler that use the same name.

PYTHONPATH=python python -m pytest tests/duplicate_handlers.py

The tests fail without the change (DID NOT RAISE ValueError, 3 failed) and pass with it (3 passed).

@github-actions

Copy link
Copy Markdown


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@RaphaelFakhri

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

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.

Registering two handlers with same name should fail at startup

1 participant