apache/apisix

bug: the routes with vars parametes , whos max match is not supported.(route的vars匹配规则不支持最大匹配)

Open

#9.431 aberto em 8 de mai. de 2023

Ver no GitHub
 (9 comments) (0 reactions) (1 assignee)Lua (2.860 forks)batch import
enhancementgood first issue

Métricas do repositório

Stars
 (16.597 stars)
Métricas de merge de PR
 (Mesclagem média 6d 8h) (109 fundiu PRs em 30d)

Description

Current Behavior

the routes with vars parametes , whos max match is not supported.

Expected Behavior

i respected match the route of test_route_2.

Error Logs

init.lua:514: http_access_phase(): matched route: {"key":"\/apisix\/routes\/1","createdIndex":152570,"modifiedIndex":218593,"value":{"vars":[["http_parameter1","~~","value[2,3]"]],upstream":{"type":"roundrobin","scheme":"http","hash_on":"vars","parent":{"key":"\/apisix\/routes\/1","createdIndex":152570,"modifiedIndex":218593,"value":"table: 0x7f009f38a618","clean_handlers":"table: 0x7f009f1f3f70","has_domain":true,"update_count":0,"orig_modifiedIndex":218593},"nodes":[{"host":"www.test1.com","weight":1}],"pass_host":"node"},"priority":0,"uri":"\/*","create_time":1673344005,"name":"test_route_2","plugin_config_id":"plugin-config","status":1,"id":"1"},"clean_handlers":{},"has_domain":true,"update_count":0,"orig_modifiedIndex":218593},

Steps to Reproduce

If i add two routes at the same time test_route_1:

curl http: //127.0.0.1:9180/apisix/admin/routes/1 -H 'X-API-KEY: 88888' -X PUT -i -d '
{
  "name": "test_route_1",
  "vars": [
    [
      "http_parameter1",
      "~~",
      "value[2,3]"
    ]
  ],
  "plugin_config_id": "plugin-config",
  "upstream": {
    "pass_host": "node",
    "nodes": {
      "www.test1.com": 1
    },
    "scheme": "http",
    "type": "roundrobin",
    "hash_on": "vars"
  },
  "status": 1,
  "priority": 0,
  "uri": "\/*"
}'

test_route_2:

curl http://127.0.0.1:9180/apisix/admin/routes/2 -H 'X-API-KEY: 88888' -X PUT -i -d '
{
  "name": "test_route_2",
  "vars": [
    [
      "http_parameter1",
      "~~",
      "value[2,3]"
    ],
    [
      "http_parameter2",
      "==",
      "2"
    ]
  ],
  "plugin_config_id": "plugin-config",
  "priority": 0,
  "upstream": {
    "pass_host": "node",
    "nodes": {
      "www.test2.com": 1
    },
    "type": "roundrobin",
    "scheme": "http"
  },
  "uri": "/*",
  "status": 1
}'

then i take a request,like:

curl 127.0.0.1:9080 -H "parameter1: value2" -H "parameter2: 2"

it will always match the route of test_route_1,but i respected match the route of test_route_2.

Environment

  • APISIX version (run apisix version):3.0.0
  • Operating system (run uname -a):CentOS Linux release 7.9.2009 (Core)
  • 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):3.0.0
  • APISIX Dashboard version, if relevant:
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):

Guia do colaborador