ThreeMammals / Ocelot

.NET API Gateway
https://www.nuget.org/packages/Ocelot
MIT License
8.31k stars 1.63k forks source link

Incorrect Routing when a configuration exists with query param wildcard #2132

Open garv-daga opened 1 month ago

garv-daga commented 1 month ago

Ocelot now matches routes incorrectly. This started breaking between versions 22.0.1 and 23.0.0.

If I have two configurations -

{
  "Routes": [
    {
      "DownstreamHostAndPorts": [
        {
          "Host": "{Endpoint1}"
        }
      ],
      "DownstreamPathTemplate": "/api/v1/abc?{everything}",
      "DownstreamScheme": "https",
      "UpstreamPathTemplate": "/api/v1/abc?{everything}"
    },
    {
      "DownstreamHostAndPorts": [
        {
          "Host": "{Endpoint2}"
        }
      ],
      "DownstreamPathTemplate": "/api/v1/{everything}",
      "DownstreamScheme": "https",
      "UpstreamPathTemplate": "/api/v1/abc2/{everything}"
    }
  ]
}

Now if I initiate a call with /api/v1/abc2/apple?isRequired=1

Expected Route: {Endpoint2}/api/v1/apple?isRequired=1

Actually Routes to: {Endpoint1}/api/v1/abc?isRequired=1"

Similar issue reported in: Originally posted by @Burgyn in https://github.com/ThreeMammals/Ocelot/discussions/2065

raman-m commented 1 month ago

Duplicate of #2064 #2065

raman-m commented 1 month ago

Thanks for reporting this! Are you C# developer?

garv-daga commented 1 month ago

Thanks for reporting this! Are you C# developer?

Thanks, Yes C# developer.

raman-m commented 1 month ago

Could you look into the issue by debugging the solution and examining Ocelot's code when you have some spare time, please? I am currently swamped with tasks for the v23.3 Hotfixes. I anticipate an open PR that will shed light on the issue, which I suspect might be related to a Regex problem.