Skip to content

Fix [SagaIdentityFrom] ignored when NotFound declared before Handle#2522

Merged
jeremydmiller merged 1 commit intomainfrom
fix/saga-identity-from-ordering-2521
Apr 16, 2026
Merged

Fix [SagaIdentityFrom] ignored when NotFound declared before Handle#2522
jeremydmiller merged 1 commit intomainfrom
fix/saga-identity-from-ordering-2521

Conversation

@jeremydmiller
Copy link
Copy Markdown
Member

Summary

  • Fixes SagaIdentityFrom attribute is not taken into account if NotFound handler is defined above. #2521[SagaIdentityFrom] attribute was silently ignored when a NotFound handler was declared before the Handle method in a saga class
  • Root cause: SagaChain used DistinctBy(x => x.HandlerType) to pick a single representative handler, then only scanned that one method's parameters for [SagaIdentityFrom]. Since Type.GetMethods() returns methods in declaration order, NotFound won the race when declared first — and it doesn't carry the attribute
  • Fix: DetermineSagaIdMember now accepts all saga handler methods (MethodInfo[]) and scans all of them for [SagaIdentityFrom]. All three SagaChain constructor paths updated to pass the full method set

Test plan

  • New integration test Bug_2521_saga_identity_from_ordering — verifies saga ID is correctly resolved from [SagaIdentityFrom] when NotFound is declared before Handle
  • New unit tests in saga_id_member_determination — verifies DetermineSagaIdMember finds the attribute when scanning multiple methods
  • Existing Bug_2056_saga_code_generation tests pass (no regression)
  • All 7 saga_id_member_determination tests pass

🤖 Generated with Claude Code

#2521)

DetermineSagaIdMember was only scanning the first handler method found
via DistinctBy, which would be NotFound if declared first in source.
Since NotFound doesn't carry [SagaIdentityFrom], the attribute was
silently ignored and saga ID resolution fell back to the envelope.

Fix: scan ALL saga handler methods for [SagaIdentityFrom] instead of
just the first one. Added new overload accepting MethodInfo[] and
updated all three SagaChain constructor paths.

Closes #2521

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

SagaIdentityFrom attribute is not taken into account if NotFound handler is defined above.

1 participant