imjoey opened a new issue #4150: URL: https://github.com/apache/apisix/issues/4150
### Issue description Regarding the `response-rewrite` plugin, the Admin API does additional checks for schema definition, such as checking whether the `body` is a valid base64 string if `body_base64` is set to `true`. While the Manager API only use `schema.json` for checking the type of properties. This would lead to incorrect data could be successfully submitted via the Dashboard, but errors occur when APISIX is trying to load them from etcd. ### Environment * apisix version (cmd: `apisix version`): 2.4 and master * OS (cmd: `uname -a`): MacOS * OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`): nginx version: openresty/1.19.3.1 * etcd version, if have (cmd: run `curl http://127.0.0.1:9090/v1/server_info` to get the info from server-info API): * apisix-dashboard version, if have: 2.6 ### Minimal test code / Steps to reproduce the issue 1. In the dashboard, create a route with `response-rewrite` plugin enabled; 2. Configure the `response-rewrite` plugin to only consist of the `body_base64` equals to `true` ```json { "body_base64" : true, } ``` 3. Submit the configurations ### What's the actual result? (including assertion message & call stack if applicable) 1. The route creation could be successfully submitted. 2. APISIX(v2.4) continuously generate the following logs: ``` 2021/04/28 14:45:09 [error] 348311#348311: *30 [lua] config_etcd.lua:552: failed to fetch data from etcd: ...xiran/product/apisix/apisix/plugins/response-rewrite.lua:84: string argument only stack traceback: [C]: in function 'error' /usr/local/openresty/lualib/resty/core/base64.lua:98: in function 'decode_base64' ...xiran/product/apisix/apisix/plugins/response-rewrite.lua:84: in function 'check_schema' /home/liuxiran/product/apisix/apisix/plugin.lua:572: in function 'plugin_checker' /home/liuxiran/product/apisix/apisix/http/route.lua:106: in function 'checker' /home/liuxiran/product/apisix/apisix/core/config_etcd.lua:357: in function 'sync_data' /home/liuxiran/product/apisix/apisix/core/config_etcd.lua:526: in function </home/liuxiran/product/apisix/apisix/core/config_etcd.lua:516> [C]: in function 'xpcall' /home/liuxiran/product/apisix/apisix/core/config_etcd.lua:516: in function </home/liuxiran/product/apisix/apisix/core/config_etcd.lua:507>, etcd key: /apisix/routes, context: ngx.timer ``` ### What's the expected result? If we submit that configuration, the page should prompt with the error `invalid base64 content`, which is should be the same as what the APISIX AdminAPI returns. -- 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. For queries about this service, please contact Infrastructure at: [email protected]
