[WCF] Fix exception when no endpoint action#4026
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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
nullAction when building action mappings for both client and service paths. - Add a unit test ensuring
ChannelFactory.Open()does not throw when a client operation hasnullAction. - 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.
| [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(); | ||
| } | ||
| } |
There was a problem hiding this comment.
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.
Fix `ArgumentNullException` when an endpoint's operation action is null. Fixes open-telemetry#2584.
Add PR number.
Kielek
left a comment
There was a problem hiding this comment.
Changes LGTM.
I am not sure if we should track help pages. If needed, we could improve it as follow ups.
3d15483
Fixes #2584
Changes
Fix
ArgumentNullExceptionwhen an endpoint's operation action is null.Merge requirement checklist
CHANGELOG.mdfiles updated for non-trivial changesChanges in public API reviewed (if applicable)