dd-trace-go icon indicating copy to clipboard operation
dd-trace-go copied to clipboard

[BUG] contrib/dimfeld/httptreemux.v5: default resource namer incorrectly replaces path variables

Open devilleweppenaar opened this issue 1 year ago • 1 comments

Version of dd-trace-go

v1.65.1

Describe what happened:

The default resource name in the contrib/dimfeld/httptreemux.v5 package has a bug where the path variable replacement fails under certain conditions.

E.g. if you have a route /foo/2by4/bar/:n and request path /foo/2by4/2 then the code will attempt to replace the first occurrence of /2 with /:n which will result in the path: /foo/:nby4/2.

Describe what you expected:

The code should replace the correct variable and leave the rest of the path unaltered.

Steps to reproduce the issue:

  1. Include the router in a project.
  2. Register a handler for an endpoint, eg. GET /foo/2by4/bar/:n
  3. Call the endpoint with the following: GET /foo/2by4/2

Additional environment details (Version of Go, Operating System, etc.):

devilleweppenaar avatar Aug 07 '24 16:08 devilleweppenaar

Thanks for reaching out. We'll review this and fix the issue.

darccio avatar Aug 13 '24 10:08 darccio