Skip to content

Query parameter names containing id are corrupted when another route has {id} placeholder (Regression in 23.4.3) #2346

@bhargav-polara

Description

@bhargav-polara

After upgrading to Ocelot 23.4.3, query parameters whose names contain the substring id (e.g. customer_id) are incorrectly rewritten when another route with a {id} path parameter exists.

This causes query parameters to be corrupted and forwarded incorrectly to downstream services.

Routes Configuration

{
  "Routes": [
    {
      "UpstreamPathTemplate": "/finance/v1/payment-methods/{id}",
      "UpstreamHttpMethod": [ "Get" ],
      "DownstreamPathTemplate": "/v1/payment-methods/{id}",
      "DownstreamScheme": "http",
      "DownstreamHostAndPorts": [
        {
          "Host": "localhost",
          "Port": 5003
        }
      ]
    },
    {
      "UpstreamPathTemplate": "/finance/v1/payment-methods",
      "UpstreamHttpMethod": [ "Get" ],
      "DownstreamPathTemplate": "/v1/payment-methods",
      "DownstreamScheme": "http",
      "DownstreamHostAndPorts": [
        {
          "Host": "localhost",
          "Port": 5003
        }
      ]
    }
  ]
}

Steps to Reproduce

Call the second route with a query parameter:
GET /finance/v1/payment-methods?customer_id=5172980

Expected Behavior

Downstream request:
/v1/payment-methods?customer_id=5172980

Query parameters must remain unchanged.

Actual Behavior

Ocelot rewrites the query parameter:
/v1/payment-methods?customer5172980

The id substring in customer_id is incorrectly treated as a route token and removed.

Ocelot Version

  • 23.4.3

Previously Working

  • Yes (22.x and earlier 23.x)

Metadata

Metadata

Assignees

No one assigned

    Labels

    RoutingOcelot feature: RoutingbugIdentified as a potential bugneeds validationIssue has not been replicated or verified yet

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions