So we have a number of mapped urls, and up until recently they were working fine. We recently noticed that our requests are inconsistently being routed to the wrong APIs.
As you can see, the format of the API urls is similar, but different. The problem we are encountering is that if we attempt to hit the second API with the following request URL
Salesforce is sometimes interpreting the request parameters as
param1 = 123/param2/abc param3 = xyz
Which is the first API URL, when it should be utilizing the second mapped API URL giving us the parameters
param1 = 123 param2 = abc param3 = xyz
This functionality seems to contradict the documentation which states
The rules for mapping URLs are:
An exact match always wins.
If no exact match is found, find all the patterns with wildcards that match, and then select the longest (by string length) of those.
If no wildcard match is found, an HTTP response status code 404 is returned.
This isn't the only inconsistency we are finding in our API calls; for example, we are also getting METHOD_NOT_ALLOWED errors for API classes that absolutely contain those methods. However, This also seems to relate to the same routing issue.
It is worth noting, similar issues have occurred as far back as 2014, I was just hoping a more recent solution may have popped up: Rest Routing with Multiple Wildcards / Supporting REST Routing for Nested Resources