wklken opened a new issue, #9366:
URL: https://github.com/apache/apisix/issues/9366

   ### Current Behavior
   
   Add two route, 
   - `short`: `GET /api/prod/:version/test/*`
   - `long`: `GET 
/api/prod/:version/test/api/portal/projects/:project_id_/clusters/:cluster_id/nodes/?`
   
   and `curl -vv 
http://{}:{}/api/prod/v4/test/api/portal/projects/saas/clusters/123/nodes/`
   
   if
   - add route `short` first, then add route `long` => the request will match 
route `short`
   - add route `long` first, then add route `short` => the request will match 
route `long`
   
   
   
   ```
   apisix:
     router:
       http: radixtree_uri_with_parameter
   ```
   
   
   
   ### Expected Behavior
   
   the curl should always match the route `long`
   
   We tested the same route in golang(use [chi](https://github.com/go-chi/chi), 
always match the `long`
   
   But in apisix 2.15.1 / 2.15.3 / 3.2.0, the adding order always affect the 
route match;
   
   
   
   ### Error Logs
   
   no error logs
   
   ### Steps to Reproduce
   
   1. apisix config
   ```yaml
   apisix:
     router:
       http: radixtree_uri_with_parameter
   deployment:
     role: traditional
     role_traditional:
       config_provider: etcd
     admin:
       admin_key:
         - name: bk-apigateway
           key: nAUkdPjuIiAlVBKkWNsfRNpV7Eh3NZIw
           role: admin
       allow_admin: # 
http://nginx.org/en/docs/http/ngx_http_access_module.html#allow
         - ::/64
         - 127.0.0.0/24
       admin_listen: # use a separate port
         ip: 127.0.0.1
         port: 9180
   ```
   
   2. delete the route via api
   ```bash
   curl -XDELETE 'http://127.0.0.1:9180/apisix/admin/routes/test.1'  -H 
'X-API-KEY: nAUkdPjuIiAlVBKkWNsfRNpV7Eh3NZIw'
   curl -XDELETE 'http://127.0.0.1:9180/apisix/admin/routes/test.2'  -H 
'X-API-KEY: nAUkdPjuIiAlVBKkWNsfRNpV7Eh3NZIw'
   ```
   
   3. add route `short` first, then add `long`
   ```bash
   curl -XPUT 'http://127.0.0.1:9180/apisix/admin/routes/test.1'  -H 
'X-API-KEY: nAUkdPjuIiAlVBKkWNsfRNpV7Eh3NZIw' -d '{
       "name": "prod-short",
       "plugins": {
          "mocking": {
             "content_type": "application/json",
             "response_status": 200,
             "response_example": "short"
          }
       },
       "uris": [
         "/api/prod/:version/test",
         "/api/prod/:version/test/*subpath_match_param_name"
       ],
       "status": 1,
       "methods": [
         "GET"
       ],
       "timeout": {
         "send": 30,
         "read": 30,
         "connect": 30
       },
       "create_time": 1682336180,
       "update_time": 1682345264,
       "id": "test.1",
       "upstream": {
           "type": "roundrobin",
           "nodes": {
               "127.0.0.1:1980": 1
           }
       }
     }'
   ```
   
   ```bash
   curl -XPUT 'http://127.0.0.1:9180/apisix/admin/routes/test.2'  -H 
'X-API-KEY: nAUkdPjuIiAlVBKkWNsfRNpV7Eh3NZIw' -d '{
       "name": "prod-long",
       "plugins": {
          "mocking": {
             "content_type": "application/json",
             "response_status": 200,
             "response_example": "long"
          }
       },
       "status": 1,
       "timeout": {
         "send": 30,
         "read": 30,
         "connect": 30
       },
       "methods": [
         "GET"
       ],
       "uri": 
"/api/prod/:version/test/api/portal/projects/:project_id_/clusters/:cluster_id/nodes/?",
   
       "create_time": 1682336179,
       "update_time": 1682345264,
       "id": "test.2",
       "upstream": {
           "type": "roundrobin",
           "nodes": {
               "127.0.0.1:1980": 1
           }
       }
     }'
   ```
   
   4. then curl, will got `response.body=short`
   ```bash
   curl 
'http://{ip}:{port}/api/prod/v4/test/api/portal/projects/saas/clusters/123/nodes/'
   short
   ```
   
   5. delete both route, then use the command in step `3`, but change the 
order, add route `long` first, then add route `short`
   
   6. then curl, will got `response.body=long`
   ```bash
   curl 
'http://{ip}:{port}/api/prod/v4/test/api/portal/projects/saas/clusters/123/nodes/'
   long
   ```
   
   
   
   ### Environment
   
   - APISIX version (run `apisix version`):  3.2.0 / 2.15.1 / 2.15.3 (same 
`lua-resty-radixtree = 2.8.2`)
   - Operating system (run `uname -a`): 
   - OpenResty / Nginx version (run `openresty -V` or `nginx -V`): 
openresty/1.21.4.1
   - etcd version, if relevant (run `curl 
http://127.0.0.1:9090/v1/server_info`): 
   - APISIX Dashboard version, if relevant:
   - Plugin runner version, for issues related to plugin runners:
   - LuaRocks version, for installation issues (run `luarocks --version`): 3.8.0
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to