You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit was created on GitHub.com and signed with GitHubβs verified signature.
β¨ Added
Saga step result includes saga ID β Each SagaStepResult yielded from saga execution now carries a saga_id field (uuid.UUID | None). This lets client code identify which saga a step belongs to and, if desired, trigger compensation immediately when a saga fails mid-way (e.g. via a dedicated API that runs compensation for a given saga_id).
π§ Changed
Stricter typing for SagaStepResult.step_type β The step_type field is now typed as type[SagaStepHandler[ContextT, Resp]] instead of typing.Any, improving type safety and IDE support without introducing new dependencies or circular imports (both types live in the same module).
π Technical details
SagaTransaction sets saga_id on each yielded SagaStepResult via dataclasses.replace() so that every step result has the current saga's ID when consumed from mediator.stream() or saga.transaction().
saga_id is optional (None by default) so that results created outside the execution layer (e.g. in step handlers via _generate_step_result()) remain valid; the execution layer fills it in when yielding to the client.
β οΈ Compatibility
Backward compatible β New field saga_id has a default of None. Existing code that does not use saga_id continues to work unchanged. The change to step_type is annotation-only; runtime behavior is unchanged.