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: built-in variables are not supported in _meta.filter #8251

Closed
bzp2010 opened this issue Nov 5, 2022 · 1 comment · Fixed by #8256
Closed

bug: built-in variables are not supported in _meta.filter #8251

bzp2010 opened this issue Nov 5, 2022 · 1 comment · Fixed by #8256
Assignees
Labels
bug Something isn't working

Comments

@bzp2010
Copy link
Contributor

bzp2010 commented Nov 5, 2022

Current Behavior

The filters in the plugin support only Nginx variables, not APISIX's built-in variables.

For example, I can use the Nginx variable http_xxx, but I can't use APISIX custom variables like arg_xxxx or graphql_xxxx.

Expected Behavior

It can support all APISIX variable syntax, including cookie_xxxx, arg_xxxx, post_arg_xxxx, graphql_xxxx, etc.

Error Logs

No response

Steps to Reproduce

  1. Set the filter in the plugin to use the above unsupported syntax.

The reason is that we didn't pass in our ctx for that expr executor, and the expr uses its default ngx.var, which wouldn't support extended syntax.

https://github.com/apache/apisix/blob/master/apisix/plugin.lua#L437
https://github.com/api7/lua-resty-expr/blob/main/lib/resty/expr/v1.lua#L376

We just need to change it to ok, err = ex:eval(ctx.var) and it will support those extended syntaxes.

Environment

  • APISIX version (run apisix version): 3.0.0
@soulbird soulbird added the bug Something isn't working label Nov 5, 2022
@soulbird
Copy link
Contributor

soulbird commented Nov 5, 2022

I will fix it later.

spacewander pushed a commit that referenced this issue Nov 7, 2022
Co-authored-by: soulbird <zhaothree@gmail.com>
Fixes #8251
spacewander pushed a commit to spacewander/incubator-apisix that referenced this issue Nov 9, 2022
spacewander pushed a commit that referenced this issue Nov 10, 2022
Co-authored-by: soulbird <zhaothree@gmail.com>
Fixes #8251
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants