Skip to content

Don't override pipeline Error status in InlineReceiver (GH-3288) - #3292

Merged
jeremydmiller merged 2 commits into
mainfrom
fix/inline-receiver-activity-status-3288
Jul 5, 2026
Merged

jeremydmiller merged 2 commits into
mainfrom
fix/inline-receiver-activity-status-3288

Conversation

@jeremydmiller

Copy link
Copy Markdown
Member

Fixes #3288

Problem

InlineReceiver starts a "receive" activity and threads it into HandlerPipeline.InvokeAsync(envelope, listener, activity). When a handler throws, Executor.ExecuteAsync sets Activity.Current (which is that receive activity) to Error — but rather than rethrow, it returns an error-handling continuation (dead-letter / discard / retries exhausted). The failure is contained, so no exception propagates out of InvokeAsync.

Back in InlineReceiver, the success path then ran activity?.SetStatus(ActivityStatusCode.Ok) unconditionally, clobbering the Error status the pipeline had already set. With a batch export processor this also races the export and the span can ship as Ok.

Fix

Only mark the activity Ok when it isn't already flagged as an Error:

if (activity is { Status: not ActivityStatusCode.Error })
{
    activity.SetStatus(ActivityStatusCode.Ok);
}

Reproduction / tests

Added inline_receiver_activity_status.cs (broker-free unit tests):

  • does_not_override_error_status_set_by_the_pipeline — a substitute IHandlerPipeline flags the passed-in activity Error without throwing (simulating a contained failure); an ActivityListener captures the stopped "receive" activity. Fails on main (span ends Ok), passes with the fix.
  • marks_ok_on_the_happy_path — guards the normal success path.

All 14 inline_receiver tests green.

🤖 Generated with Claude Code

jeremydmiller and others added 2 commits July 5, 2026 09:11
GH-3288)

When a handler fails but the failure is contained by an error-handling
continuation (dead-letter, discard, retries exhausted), Executor.ExecuteAsync
flags the receive Activity as Error without rethrowing, so no exception
propagates out of HandlerPipeline.InvokeAsync. InlineReceiver's success path
then unconditionally called SetStatus(Ok), clobbering that Error status.

Only mark the activity Ok when it isn't already flagged as an Error.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jeremydmiller
jeremydmiller merged commit ac30cbc into main Jul 5, 2026
26 checks passed
This was referenced Jul 9, 2026
This was referenced Jul 28, 2026
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.

InlineReceiver overrides activity status set by HandlerPipeline

1 participant