Skip to content

Fix duplicate fault response on the error path #1192 - #1193

Merged
andersjonsson merged 2 commits into
DigDes:developfrom
juergotter:fix/1192-duplicate-fault-response
Sep 11, 2026
Merged

andersjonsson merged 2 commits into
DigDes:developfrom
juergotter:fix/1192-duplicate-fault-response

Conversation

@juergotter

Copy link
Copy Markdown
Contributor

Fixes #1192.

Change

The catch in ProcessMessage is removed, and IMessageInspector2.BeforeSendReply is invoked from the catch in ProcessOperation, on the message that is written to the response.

The correlation objects are created in ProcessMessage, so ProcessOperation creates the list and passes it in. AfterReceiveRequest stays inside the ISoapMessageProcessor pipe, and ProcessMessage is private, so no public API is affected. The list is cleared once the inspectors have seen the reply, so a failure later in the response path cannot notify them a second time.

Measured

Repro from the issue, single POST to an operation that throws:

v1.2.1.15 this branch
Error entries "An error occurred processing the message" 2 1
IFaultExceptionTransformer.ProvideFault invocations 2 1
IMessageInspector2.AfterReceiveRequest invocations 1 1
IMessageInspector2.BeforeSendReply invocations 1 1
Header added by BeforeSendReply present in the fault received by the client no yes

Adjacent paths

Path Behaviour
exception before any AfterReceiveRequest no inspector notified, unchanged
one inspector throws in AfterReceiveRequest the inspectors before it are notified, keeping their calls paired
ISoapMessageProcessor swallows the exception and returns its own message no fault built, so no log entry and no notification
inspector throws in BeforeSendReply the exception leaves the middleware, so the client gets a plain 500 instead of a fault

Tests

src/SoapCore.Tests/DuplicateFault runs a TestServer with a counting IFaultExceptionTransformer, an IMessageInspector2 that stamps a header onto the reply, and an ILoggerProvider that records Error entries. One faulting request asserts the rows of the table above. A fifth test asserts that a successful operation followed by a throwing IAsyncMessageFilter.OnResponseExecuting notifies the inspectors once.

Three of the five fail on develop.

Note

dotnet test src/SoapCore.Tests: 292 of 293 pass. TestIssue1183 fails on develop as well.

@andersjonsson

Copy link
Copy Markdown
Collaborator

Great! Thank you! Will make a new release shortly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants