Skip to content

[WCF] Fix exception when no endpoint action#4026

Merged
martincostello merged 6 commits into
open-telemetry:mainfrom
martincostello:gh-2584
Apr 28, 2026
Merged

[WCF] Fix exception when no endpoint action#4026
martincostello merged 6 commits into
open-telemetry:mainfrom
martincostello:gh-2584

Conversation

@martincostello
Copy link
Copy Markdown
Member

Fixes #2584

Changes

Fix ArgumentNullException when an endpoint's operation action is null.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

@github-actions github-actions Bot added the comp:instrumentation.wcf Things related to OpenTelemetry.Instrumentation.Wcf label Mar 27, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.97%. Comparing base (290bae6) to head (b6ed4cd).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4026      +/-   ##
==========================================
- Coverage   75.98%   75.97%   -0.01%     
==========================================
  Files         466      466              
  Lines       18564    18556       -8     
==========================================
- Hits        14105    14098       -7     
+ Misses       4459     4458       -1     
Flag Coverage Δ
unittests-Instrumentation.Wcf 81.44% <100.00%> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...y.Instrumentation.Wcf/TelemetryEndpointBehavior.cs 91.89% <100.00%> (+0.46%) ⬆️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread src/OpenTelemetry.Instrumentation.Wcf/CHANGELOG.md Outdated
@martincostello martincostello marked this pull request as ready for review March 27, 2026 15:56
@martincostello martincostello requested a review from a team as a code owner March 27, 2026 15:56
Copilot AI review requested due to automatic review settings March 27, 2026 15:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a WCF instrumentation crash when an operation’s SOAP Action is missing by preventing TelemetryEndpointBehavior from inserting null keys into its action-to-metadata map (addressing scenarios like WCF Web HTTP help pages).

Changes:

  • Skip operations with null Action when building action mappings for both client and service paths.
  • Add a unit test ensuring ChannelFactory.Open() does not throw when a client operation has null Action.
  • Document the fix in the WCF instrumentation changelog.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
test/OpenTelemetry.Instrumentation.Wcf.Tests/TelemetryEndpointBehaviorTests.cs Adds coverage for the client-side null Action scenario.
src/OpenTelemetry.Instrumentation.Wcf/TelemetryEndpointBehavior.cs Avoids ArgumentNullException by handling null Action values when building action mappings.
src/OpenTelemetry.Instrumentation.Wcf/CHANGELOG.md Records the bug fix in Unreleased notes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/OpenTelemetry.Instrumentation.Wcf/TelemetryEndpointBehavior.cs
Comment on lines +14 to +35
[Fact]
public void ApplyClientBehaviorToClientRuntime_WithNullActionOperation_DoesNotThrow()
{
// Arrange
var contract = ContractDescription.GetContract(typeof(IServiceContract));
var endpoint = new ServiceEndpoint(contract, new BasicHttpBinding(), new EndpointAddress("http://localhost/dummy"));

endpoint.EndpointBehaviors.Add(new InjectNullActionOperationBehavior());
endpoint.EndpointBehaviors.Add(new TelemetryEndpointBehavior());

var factory = new ChannelFactory<IServiceContract>(endpoint);

try
{
var exception = Record.Exception(factory.Open);
Assert.Null(exception);
}
finally
{
factory.Abort();
}
}
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test validates the client-side fix, but the reported crash in #2584 occurs in the server-side path (ApplyDispatchBehaviorToEndpoint) when a DispatchOperation.Action is null. Add a .NET Framework-only unit test covering ApplyDispatchBehaviorToEndpoint with a DispatchOperation whose Action is null to ensure the original failure mode stays covered.

Copilot uses AI. Check for mistakes.
@martincostello martincostello added the keep-open Prevents issues and pull requests being closed as stale label Apr 7, 2026
@martincostello martincostello requested a review from Kielek April 14, 2026 16:53
Fix `ArgumentNullException` when an endpoint's operation action is null.

Fixes open-telemetry#2584.
Add PR number.
Copy link
Copy Markdown
Member

@Kielek Kielek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM.
I am not sure if we should track help pages. If needed, we could improve it as follow ups.

@martincostello martincostello added this pull request to the merge queue Apr 28, 2026
Merged via the queue into open-telemetry:main with commit 3d15483 Apr 28, 2026
124 of 127 checks passed
@martincostello martincostello deleted the gh-2584 branch April 28, 2026 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:instrumentation.wcf Things related to OpenTelemetry.Instrumentation.Wcf keep-open Prevents issues and pull requests being closed as stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] WCF tracing instrumentation fails when using WCF Web HTTP Help Pages

3 participants