Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NewRelic.Parsing.StringsHelper.CleanURI() throws InvalidOperationException #2373

Closed
tippmar-nr opened this issue Mar 26, 2024 · 1 comment · Fixed by #2374
Closed

NewRelic.Parsing.StringsHelper.CleanURI() throws InvalidOperationException #2373

tippmar-nr opened this issue Mar 26, 2024 · 1 comment · Fixed by #2374
Labels
bug Something isn't working

Comments

@tippmar-nr
Copy link
Member

tippmar-nr commented Mar 26, 2024

Description
The .NET agent throws an unhandled exception

System.InvalidOperationException: GetComponents() may not be used for Path/Query on a Uri instance created with UriCreationOptions.DangerousDisablePathAndQueryCanonicalization.
   at NewRelic.Parsing.StringsHelper.CleanUri(Uri uri)
   at NewRelic.Agent.Core.Segments.ExternalSegmentData.Finish()
   at NewRelic.Agent.Core.Segments.Segment.Finish()
   at NewRelic.Agent.Core.Segments.Segment.End()
   at NewRelic.Agent.Extensions.Providers.Wrapper.Delegates.<>c__DisplayClass8_1`1.<OnSuccess>g__EndSegmentWithPossibleException|1()
   at NewRelic.Agent.Extensions.Providers.Wrapper.IAgentWrapperExtensions.HandleExceptions(IAgent agent, Action action)".

when presented with a Uri that has been created with UriCreationOptions.DangerousDisablePathAndQueryCanonicalization = true:

		var options = new UriCreationOptions 
		{
			DangerousDisablePathAndQueryCanonicalization = true
		};
		var uri = new Uri(@"http://myhost.com/some/path?param1=1", options);	

               // boom
                var foo = uri.GetComponents(
                                     UriComponents.Scheme |
                                     UriComponents.HostAndPort |
                                     UriComponents.Path,
                                     UriFormat.UriEscaped);

Expected Behavior
The .NET agent should handle the exception.

Steps to Reproduce
Requires a .NET 6+ application that somehow sets UriCreationOptions.DangerousDisablePathAndQueryCanonicalization = true. It's not clear how one might go about setting that flag, but the solution is pretty clear -- handle the InvalidOperationException and return CleanUri(uri.ToString()) instead.

Additional context
Customer reported issue

For Maintainers Only or Hero Triaging this bug
Suggested Priority (P1,P2,P3,P4,P5):
P2
Suggested T-Shirt size (S, M, L, XL, Unknown):
S

@tippmar-nr tippmar-nr added the bug Something isn't working label Mar 26, 2024
@workato-integration
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant