elsa-core/src/clients/Elsa.Api.Client
Sipke Schoorstra 5faba75906
fix(core): a fault a container claimed is not an incident (#7923)
* fix(core): a fault a container claimed is not an incident (#7911)

RecoverFromFault reset the counts and the status but left behind the two other
things Fault recorded: the ActivityIncident and the exception. So a container
that successfully handled a child's fault still left the workflow carrying an
incident.

That is not cosmetic. Code reads a non-empty WorkflowExecutionContext.Incidents
as "this workflow failed" without looking further; HttpWorkflowsMiddleware is
one, and it hands the caller a fault response. A workflow whose container caught
the error and finished normally was reported to its caller as failed.

RecoverFromFault is now the inverse of Fault: it removes the incident Fault
appended, matched on this activity's node id and most recent first so an
activity that faults, recovers and faults again keeps the incident that was
never recovered, and it clears the recorded exception so the activity does not
sit in Running carrying one.

The execution log still records the failure, so nothing is hidden from anyone
reading the journal. Two integration assertions that encoded the old behaviour
are updated; they were written from the reasoning this change corrects.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(core): tie an incident to the execution that raised it, not its node

Recovery matched the incident to remove on ActivityNodeId, which identifies the
static workflow node rather than an execution of it. A node inside a loop,
retried, or run concurrently raises one incident per execution, all under the
same node id, so recovering one execution could remove another's incident and
leave its own behind.

ActivityIncident now carries the ActivityInstanceId of the execution that raised
it, and recovery matches on that. Within a single execution the most recent is
still taken, so fault, recover, fault again keeps the incident that was never
recovered. The property is optional: an incident recorded against the workflow
itself has no execution, and so do incidents persisted before this existed.

Caught by review on #7923.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(api-client): mirror ActivityInstanceId on the client incident model

The server model gained the property in the previous commit and the API client
carries a hand-maintained copy of it. Left alone, a client deserializing an
incident would silently drop the only field that says which execution raised it.

Also records two consequences of recovery that were implicit: it relies on the
incident collection preserving insertion order to pick an execution's newest
incident, which holds only because the collection is list-backed; and clearing
the exception also clears it from the activity's execution record, which is
intended for the same reason the incident goes, with the journal keeping the
evidence either way.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-12 05:20:22 +02:00
..
Converters Add TypeJsonConverter and enhance JSON serialization 2024-10-03 18:50:05 +02:00
Extensions Add output converter support at binding boundaries 2026-07-31 04:10:48 +02:00
Helpers Refactor RefitSettingsHelper for improved readability 2025-02-08 10:10:40 +01:00
HttpMessageHandlers Add API key authentication for Elsa client 2023-12-28 21:54:06 +01:00
Options Removed unwanted code 2025-02-06 12:49:04 +02:00
RealTime/Messages Implement real time workflow update broadcasting using SignalR 2023-07-25 15:12:27 +02:00
Resources fix(core): a fault a container claimed is not an incident (#7923) 2026-08-12 05:20:22 +02:00
Serialization Add IResilienceStrategy Abstraction with Category Matching and Expression-Based Configuration (#6637) 2025-05-12 10:09:04 +02:00
Shared Add output converter support at binding boundaries 2026-07-31 04:10:48 +02:00
Elsa.Api.Client.csproj Create Api Client Models for upcoming RadioList UIHint. 2025-06-05 00:36:18 +01:00
Elsa.Api.Client.csproj.DotSettings Introduce Log Persistence Strategy (#6057) 2024-10-25 19:41:10 +02:00
FodyWeavers.xml Implement API key authentication (#3834) 2023-03-26 23:53:17 +02:00