[Mocha] Fix the mediator throwing when a notification has no handlers - #10465
Merged
Merged
Conversation
Contributor
Patch coverage100.0% of changed lines covered (11/11)
Project coverage: 57.8% (299398/518184 lines) |
tobias-tengler
marked this pull request as ready for review
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.
tobias-tengler
force-pushed
the
tte/mediator-publish-no-handlers
branch
from
October 2, 2026 09:18
fc1b910 to
0da5510
Compare
Contributor
There was a problem hiding this comment.
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.
PascalSenn
approved these changes
Oct 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.