Issue with request path match with regex

### Summary

We are having issue with Route matching. There are two routes configured under different services having paths with regex, where the request for only one route is matched & other is returning 404 as its matched incorrectly & sent to wrong service where that route is not hosted. We are not using any header or hosts for request path matching. We rely completely on the Path URI configured in the kong for request matching.

### Steps To Reproduce

Here is how the config is in nutshell -

Service A → Route A - > Path :- /individuals/details/(.+)/(.+)
Service B → Route B - > Path :- /individuals/details/contact/(.+)/(.+)

So any request to Route B path is directed to Service A & hence resulting in Kong returning 404. Here is link & extract from documentation for route matching - https://docs.konghq.com/2.0.x/proxy/#request-path

When proxying with path prefixes, the longest paths get evaluated first. This allow you to define two Routes with two paths: /service and /service/resource, and ensure that the former does not “shadow” the latter.

Now as per the documentation, longest path should get evaluated first so it should match Route B instead of A. Path variables in above URI’s we have regex for are - /{idType}/{idValue}.

Any suggestions on why Kong is behaving like this or how best we can achieve the desired results, without using headers/hosts if possible [reducing the impact on consumers for change], will be helpful.

### Additional Details

  • Kong version - 2.0.1

  • Kong Configuration -

For additional details, here is the Kong Config for routes in Kong DB-

**Route A :**
{
"id": "2d255493-c60b-4c75-a13b-0b92344e0964",
"path_handling": "v0",
"paths": [
"/individuals/details/contact/(.+)/(.+)"
],
"destinations": null,
"headers": null,
"protocols": [
"http",
"https"
],
"methods": [
"GET"
],
"snis": null,
"service": {
"id": "86dfb5af-eea9-4bfe-bad6-5fb6234e6dad"
},
"name": "api-B",
"strip_path": false,
"preserve_host": false,
"regex_priority": 0,
"updated_at": 1610443360,
"sources": null,
"hosts": null,
"https_redirect_status_code": 426,
"tags": null,
"created_at": 1610443360
} 

**Route B :**
{
"id": "37acf130-3085-461f-8ed6-73d3ff9f98df",
"path_handling": "v0",
"paths": [
"/individuals/details/(.+)/(.+)"
],
"destinations": null,
"headers": null,
"protocols": [
"http",
"https"
],
"methods": [
"GET"
],
"snis": null,
"service": {
"id": "faf7155c-92ff-404a-9372-c4462377cbb0"
},
"name": "api-A",
"strip_path": false,
"preserve_host": false,
"regex_priority": 0,
"updated_at": 1610443359,
"sources": null,
"hosts": null,
"https_redirect_status_code": 426,
"tags": null,
"created_at": 1610443359
}

Did you ever find a solution? I’m hitting same issue.