Skip to content

Fix event type resolver usage mismatch#1946

Open
mpraglowski wants to merge 9 commits into
masterfrom
event-type-resolver-dispatch-mismatch
Open

Fix event type resolver usage mismatch#1946
mpraglowski wants to merge 9 commits into
masterfrom
event-type-resolver-dispatch-mismatch

Conversation

@mpraglowski

Copy link
Copy Markdown
Member

No description provided.

mpraglowski and others added 9 commits July 16, 2026 18:18
Client#publish routes via event.event_type instead of the configured
event_type_resolver, so a resolver whose output differs from
event.event_type never matches its own subscriptions.

AggregateRoot::DefaultApplyStrategy has the same split: on-DSL registers
handlers via event_type_resolver, apply looks them up by
event.event_type.
Client#publish and AggregateRoot::DefaultApplyStrategy now resolve the
published/applied event's type via the configured event_type_resolver
(passing event.class, matching the subscribe/on registration side)
instead of reading event.event_type directly. A resolver whose output
differs from event.event_type now matches its own subscriptions and
aggregate handlers. Default resolver (to_s) is unchanged.
Dispatch routes by event_type_resolver.call(event.class), not by
event.event_type (which honors metadata[:event_type]). This documents
the deliberate choice: subscribe and dispatch share one key derived
from the resolver, so metadata overrides no longer silently misroute
published events.
…event_type

AggregateRoot now derives the handler key from event.event_type on the
apply path and from value.to_s at on-DSL registration, instead of an
injected event_type_resolver. The event_type_resolver keyword is kept on
AggregateRoot.with and DefaultApplyStrategy.new for backward compat but is
ignored and emits a deprecation warning when passed.
Add specs covering the branches mutant found alive:
- no deprecation warning on the default path (both AggregateRoot.with and
  DefaultApplyStrategy.new)
- deprecation key is suppressible (locks the warn key, not just the message)
- on-DSL registration key derives from the event class name

AggregateRoot mutation coverage back to 100%.
@fidel
fidel force-pushed the event-type-resolver-dispatch-mismatch branch from b392ebc to 3c734e3 Compare July 16, 2026 16:19
@mpraglowski
mpraglowski marked this pull request as ready for review July 17, 2026 10:51
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.

2 participants