Skip to content

Improve validations for explicit topologies - #9986

Merged
PascalSenn merged 5 commits into
mainfrom
pse/mocha-validations
Jun 26, 2026
Merged

PascalSenn merged 5 commits into
mainfrom
pse/mocha-validations

Conversation

@PascalSenn

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings June 25, 2026 14:46

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 strengthens “explicit topology/bind” behavior in Mocha by adding centralized validation for unbound inbound routes, improving exception diagnostics, and refining transport routing/topology discovery (notably for RabbitMQ) to better honor explicit binding semantics.

Changes:

  • Add a build-time validator that aggregates and formats all unbound inbound routes into a single actionable InvalidOperationException (with transport/endpoint hints), plus snapshot coverage.
  • Ensure reply inbound routes are bound to the reply receive endpoint during endpoint discovery.
  • Refine RabbitMQ topology discovery to avoid declaring convention publish/send exchange chains when endpoints are in explicit bind mode; improve endpoint bind-mode inheritance behavior.

Reviewed changes

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

Show a summary per file
File Description
src/Mocha/test/Mocha.Transport.RabbitMQ.Tests/Descriptors/RabbitMQHandlerBindingTests.cs Tighten explicit-bind failure assertions to validate the new aggregated error message content.
src/Mocha/test/Mocha.Transport.Postgres.Tests/Descriptors/PostgresHandlerBindingTests.cs Same as RabbitMQ: validate explicit-bind failures include the expected diagnostics.
src/Mocha/test/Mocha.Tests/MessageTypes/MessageBusConfigurationValidationTests.cs New test coverage for aggregated validation messaging + saga reply route binding behavior (with snapshots).
src/Mocha/test/Mocha.Tests/MessageTypes/snapshots/MessageBusConfigurationValidationTests.Build_Should_ReportNoTransportHint_When_HandlerRegisteredWithoutTransport.snap Snapshot for “no transport configured” validation hint.
src/Mocha/test/Mocha.Tests/MessageTypes/snapshots/MessageBusConfigurationValidationTests.Build_Should_ReportAlsoBoundElsewhere_When_SameMessageHasAnotherBoundRoute.snap Snapshot for “also bound elsewhere” hint.
src/Mocha/test/Mocha.Tests/MessageTypes/snapshots/MessageBusConfigurationValidationTests.Build_Should_ReportAllUnboundInboundRoutes_When_ExplicitBindLeavesHandlersUnbound.snap Snapshot for multiple unbound routes under explicit bind mode.
src/Mocha/test/Mocha.Tests/MessageTypes/snapshots/MessageBusConfigurationValidationTests.Build_Should_NotUseReplyRouteAsDuplicate_When_NormalRouteWithSameMessageIsUnbound.snap Snapshot ensuring reply routes don’t count as duplicates for validation hints.
src/Mocha/src/Mocha/Transport/RoutingStrategy.cs Bind all existing reply inbound routes to the reply receive endpoint when available.
src/Mocha/src/Mocha/ThrowHelper.cs Improve route-not-connected exceptions with richer context; remove the RabbitMQ-specific auto-bind helper.
src/Mocha/src/Mocha/MessageTypes/OutboundRoute.cs Use the new contextual ThrowHelper.RouteEndpointNotConnected(OutboundRoute) overload.
src/Mocha/src/Mocha/MessageTypes/InboundRoute.cs Use the new contextual ThrowHelper.RouteEndpointNotConnected(InboundRoute) overload.
src/Mocha/src/Mocha/Builder/MessageBusBuilder.Validation.cs New centralized validator + formatted diagnostics for unbound inbound routes.
src/Mocha/src/Mocha/Builder/MessageBusBuilder.cs Invoke the new validator during build prior to completing inbound routes.
src/Mocha/src/Mocha.Transport.RabbitMQ/Topology/RabbitMQRoutingStrategy.cs Adjust convention topology discovery to better respect explicit bind mode; update dispatch provisioning behavior.
src/Mocha/src/Mocha.Transport.RabbitMQ/Descriptors/RabbitMQReceiveEndpointDescriptor.cs Stop forcing receive endpoint bind mode to implicit (allow inheritance).
src/Mocha/src/Mocha.Transport.RabbitMQ/Descriptors/RabbitMQMessagingTransportDescriptor.cs Stop defaulting queue bind mode to implicit; allow null to inherit from transport bind mode.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@PascalSenn PascalSenn changed the title Imprve validations for explicit topologies Improve validations for explicit topologies Jun 25, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@PascalSenn PascalSenn left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

LGTM

PascalSenn and others added 2 commits June 25, 2026 17:37
…r explicit binding

- Updated snapshots to reflect changes in RabbitMQ topology behavior when explicit bindings are used.
- Removed unnecessary exchanges and bindings from snapshots to align with the new explicit binding logic.
- Adjusted test descriptions for clarity regarding the behavior of explicit bindings and their impact on convention entities.
- Ensured that tests accurately reflect the expected state of the RabbitMQ topology when using explicit configurations.
@PascalSenn
PascalSenn merged commit 4db00e3 into main Jun 26, 2026
145 checks passed
@PascalSenn
PascalSenn deleted the pse/mocha-validations branch June 26, 2026 06:59
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.

2 participants