Skip to content

Routing not working with special character in UpstreamPathTemplate #2143

Open
@amorelIM

Description

@amorelIM

Hi,

we're using ocelot as an API gateway for a service using OData. In OData, one feature is to have a route with $query in the name.
For example: /v3/Orders/$query

Here is the documentation for that specific thing : https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_PassingQueryOptionsintheRequestBody

Expected Behavior / New Feature

Having the next route exposed in Ocelot and being able to call the $query route on the underlying service.

{
  "UpstreamPathTemplate": "/v3/Orders/$query",
  "DownstreamPathTemplate": "/v1/Orders/$query"
}

Actual Behavior / Motivation for New Feature

A 404 is returned with those warnings in the logs:

[13:10:56 WRN] requestId: , previousRequestId: No PreviousRequestId, message: 'DownstreamRouteFinderMiddleware setting pipeline errors. IDownstreamRouteFinder returned Error Code: UnableToFindDownstreamRouteError Message: Failed to match Route configuration for upstream path: /v3/orders/$query, verb: POST.'
[13:10:56 WRN] requestId: , previousRequestId: No PreviousRequestId, message: 'Error Code: UnableToFindDownstreamRouteError Message: Failed to match Route configuration for upstream path: /v3/orders/$query, verb: POST. errors found in ResponderMiddleware. Setting error response for request path:/v3/orders/$query, request method: POST'

Steps to Reproduce the Problem

See previous sections. Using the '$' character in the upstream route.

Workaround

Remove the $ character from the upstreamPathTemplate, but it won't respect the OData protocol.

{
  "UpstreamPathTemplate": "/v3/Orders/query",
  "DownstreamPathTemplate": "/v1/Orders/$query"
}

Specifications

  • Version: 23.3.3.0
  • Platform: .NET 8
  • Subsystem: Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    RoutingOcelot feature: RoutingSpring'25Spring 2025 releasebugIdentified as a potential bug

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions