ThreeMammals / Ocelot

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

Incorrect calculation of placeholders #2212

Closed fenzad closed 3 days ago

fenzad commented 3 days ago

Expected Behavior

Path: /dati-registri/v1.0/operatore/R80QQ5J9600/valida Template: /dati-registri/{version}/{everything}

Expected: version = v1.0 everything = operatore/R80QQ5J9600/valida

Actual Behavior

version = v1.0/operatore/R80QQ5J9600 everything = valida

in the previous version, the behavior was as expected

Steps to Reproduce the Problem

Set the configuration in the gateway with an ocelot.settings.json file with an UpstreamPathTemplate as indicated in the first point and create an endpoint in the API with the path indicated in the first point.

Specifications

ggnaegi commented 3 days ago

@fenzad Thanks for your feedback, ok, I will check that. Again a test case missing on our side.

raman-m commented 3 days ago

Yes, as a CatchAll placeholder, it should cover as much path segments as it can. Moreover, I propose to have a check if placeholders are docked to each other, if yes, then first placeholders should cover data of one path segment, the last placeholder should extract data as much it can but except first docked placeholders.

ggnaegi commented 3 days ago

The problem is the main regex, it should match only between slashes. But if so, then it can't match the Catch All. So, I must invert the logic here: 1) catch all query, 2) catch all path, remove the catch all part, 3) validate the rest. At the minute we have 1) catch all query, 2) validate placeholders 3) catch all path. And that's wrong, but all tests passed ;-)