Skip to content

[Mocha] Fix the mediator throwing when a notification has no handlers - #10465

Merged
tobias-tengler merged 1 commit into
mainfrom
tte/mediator-publish-no-handlers
Oct 2, 2026
Merged

tobias-tengler merged 1 commit into
mainfrom
tte/mediator-publish-no-handlers

Conversation

@tobias-tengler

Copy link
Copy Markdown
Member

No description provided.

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Patch coverage

100.0% of changed lines covered (11/11)

File Covered Changed Patch %
src/Mocha/src/Mocha.Mediator/Mediator.cs 6 6 100.0% 🟢
src/Mocha/src/Mocha.Mediator/MediatorRuntime.cs 1 1 100.0% 🟢
src/Mocha/src/Mocha.Mediator/ThrowHelper.cs 4 4 100.0% 🟢

Project coverage: 57.8% (299398/518184 lines)

@tobias-tengler
tobias-tengler marked this pull request as ready for review October 2, 2026 09:18
Copilot AI balanced review requested due to automatic review settings October 2, 2026 09:18
Publishing a notification with zero registered handlers now completes as
a no-op, matching the docs. Send and query still throw when no handler is
registered. The untyped IPublisher.PublishAsync(object) now explicitly
throws an ArgumentException when the object does not implement
INotification.

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.

Copilot review overview

🟢 Approval recommended

The focused behavior change is consistent with the publisher contract and adequately tested.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes notification publishing so unhandled notifications complete successfully while invalid untyped messages still fail clearly.

Changes:

  • Returns an empty pipeline collection when no notification handlers exist.
  • Validates untyped notifications and adds coverage for both behaviors.
File Description
MediatorDispatchTests.cs Tests handled, unhandled, and invalid notifications.
ThrowHelper.cs Adds the invalid-notification exception.
MediatorRuntime.cs Returns an empty collection for missing handlers.
Mediator.cs Completes no-handler publishes without dispatching.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@tobias-tengler
tobias-tengler merged commit 4495c20 into main Oct 2, 2026
159 checks passed
@tobias-tengler
tobias-tengler deleted the tte/mediator-publish-no-handlers branch October 2, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants