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

Routing not working with special character in UpstreamPathTemplate #2143

Open
amorelIM opened this issue Aug 23, 2024 · 7 comments
Open

Routing not working with special character in UpstreamPathTemplate #2143

amorelIM opened this issue Aug 23, 2024 · 7 comments
Labels
bug Identified as a potential bug Dec'24 December 2024 release Routing Ocelot feature: Routing
Milestone

Comments

@amorelIM
Copy link

amorelIM commented Aug 23, 2024

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
@amorelIM amorelIM changed the title Potential bug with routing using special character in route Routing not working with special character in UpstreamPathTemplate Aug 23, 2024
@raman-m raman-m added the Routing Ocelot feature: Routing label Aug 27, 2024
@raman-m
Copy link
Member

raman-m commented Aug 27, 2024

@raman-m
Copy link
Member

raman-m commented Aug 27, 2024

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"
}

I concur that all static routes with special characters should be functional and forwarded. However, I'm curious about the rationale for defining a static route.

Why not utilize placeholders and convert templates instead?

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

or even more short version?

{
  "UpstreamPathTemplate": "/v3/{everything}",
  "DownstreamPathTemplate": "/v1/{everything}"
}

Why don't you utilize placeholders?

@raman-m
Copy link
Member

raman-m commented Aug 27, 2024

OData query is supported via using placeholders, see examples in code & docs
My old answers in discussions with the same problem.

@raman-m
Copy link
Member

raman-m commented Aug 27, 2024

Duplicate of #859

@raman-m raman-m marked this as a duplicate of #859 Aug 27, 2024
@amorelIM
Copy link
Author

Thank you, it worked.

@raman-m raman-m added the bug Identified as a potential bug label Aug 30, 2024
@raman-m raman-m reopened this Aug 30, 2024
@raman-m raman-m added the Oct'24 October 2024 release label Aug 30, 2024
@raman-m raman-m added this to the September'24 milestone Aug 30, 2024
@raman-m raman-m added Dec'24 December 2024 release and removed Oct'24 October 2024 release labels Oct 26, 2024
@raman-m raman-m modified the milestones: October'24, Autumn'24 Oct 26, 2024
@raman-m
Copy link
Member

raman-m commented Nov 8, 2024

@int0x81, welcome to your assignment!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Identified as a potential bug Dec'24 December 2024 release Routing Ocelot feature: Routing
Projects
Status: Todo
Development

No branches or pull requests

2 participants