Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: path parameter matching #154

Open
GongchuangSu opened this issue Jan 8, 2025 · 1 comment
Open

bug: path parameter matching #154

GongchuangSu opened this issue Jan 8, 2025 · 1 comment

Comments

@GongchuangSu
Copy link

When setting the route as "/api/:upload_id/info", the following request cannot be matched
/api/DCAppFile_2~9lwcn8WIw6sqq2v_Z7Wd6kLIfAhKVb0-MRKUYR2WMJKUUVTZKVLXOZKVLBXE65SOG5IUW52IOAZEE6JRNRIHEUSNOYXWI3RTJFLXEZKPJ5KU2VKIPBCHK3JUPJIUOTJSMJZECR2RPJVG643JM5YFEZLHON4XIU3Y-6XBBIO35THB6WGDDKZ63LJTWX2LVPM42PPC6RNJUNDNZB6J422ADLEQ6DVXSR2FBCWUX2TCYZASWQNRXFJ5O63KHLBHHEOEK-AES_256_ECB-1c3b94db/info
How should this be handled?

@mikyll
Copy link

mikyll commented Feb 6, 2025

I ran the following test case and it passed (resty-radixtree matches it correctly), which suggests the issue is not related to lua-resty-radixtree. Could you provide additional details? Examples:

  • how are you testing that route;
  • which version are you using (of apisix and lua-resty-radixtree);
  • what is the route configuration;
  • access/error logs;

Test

File t/long_path_param.t:

# vim:set ft= ts=4 sw=4 et fdm=marker:

use t::RX 'no_plan';

repeat_each(1);
run_tests();

__DATA__

=== TEST: long path parameter
--- config
    location /t {
        content_by_lua_block {
            local json = require("toolkit.json")
            local radix = require("resty.radixtree")
            local rx = radix.new({
                {
                    paths = {"/api/:upload_id/info"},
                    metadata = "metadata /api",
                },
            })

            local opts = {matched = {}}
            local meta = rx:match("/api/DCAppFile_2~9lwcn8WIw6sqq2v_Z7Wd6kLIfAhKVb0-MRKUYR2WMJKUUVTZKVLXOZKVLBXE65SOG5IUW52IOAZEE6JRNRIHEUSNOYXWI3RTJFLXEZKPJ5KU2VKIPBCHK3JUPJIUOTJSMJZECR2RPJVG643JM5YFEZLHON4XIU3Y-6XBBIO35THB6WGDDKZ63LJTWX2LVPM42PPC6RNJUNDNZB6J422ADLEQ6DVXSR2FBCWUX2TCYZASWQNRXFJ5O63KHLBHHEOEK-AES_256_ECB-1c3b94db/info", opts)
            ngx.say("match meta: ", meta)
            ngx.say("matched: ", json.encode(opts.matched))
        }
    }
--- request
GET /t
--- no_error_log
[error]
--- response_body
match meta: metadata /api
matched: {"_path":"/api/:upload_id/info","upload_id":"DCAppFile_2~9lwcn8WIw6sqq2v_Z7Wd6kLIfAhKVb0-MRKUYR2WMJKUUVTZKVLXOZKVLBXE65SOG5IUW52IOAZEE6JRNRIHEUSNOYXWI3RTJFLXEZKPJ5KU2VKIPBCHK3JUPJIUOTJSMJZECR2RPJVG643JM5YFEZLHON4XIU3Y-6XBBIO35THB6WGDDKZ63LJTWX2LVPM42PPC6RNJUNDNZB6J422ADLEQ6DVXSR2FBCWUX2TCYZASWQNRXFJ5O63KHLBHHEOEK-AES_256_ECB-1c3b94db"}

Test run:

prove -Itest-nginx/lib -I. -r t/long_path_param.t
t/long_path_param.t .. ok   
All tests successful.
Files=1, Tests=3,  1 wallclock secs ( 0.02 usr  0.00 sys +  0.08 cusr  0.02 csys =  0.12 CPU)
Result: PASS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants