Skip to content

bug: rejected_msg not working in limit-count plugin #5107

@tinpad

Description

@tinpad

Issue description

I am using below request to setup limit-count as global rule.

curl http://127.0.0.1:9080/apisix/admin/global_rules/111 -H 'X-API-KEY: xxxxxxxxxxxxxxxxxxxx' -X PUT -d '
{
"plugins": {
"limit-count": {
"time_window": 60,
"policy": "local",
"count": 10,
"key": "remote_addr",
"rejected_code": 429,
"rejected_msg" : "{"message":"Request Limit Exceeded"}"
}
}
}'
When I hit the below route and the count exceeds the count 10 -

http://127.0.0.1:9080/order/list?pageSize=10

I am getting 429 but not getting the response in json format as mentioned in the above route.
I am getting following html content -

<title>429 Too Many Requests</title>

429 Too Many Requests


openresty

Environment

  • apisix version (cmd: apisix version): 2.8
  • OS (cmd: uname -a): 20.04.1-Ubuntu
  • OpenResty / Nginx version (cmd: nginx -V or openresty -V): openresty/1.19.3.2
  • etcd version, if have (cmd: run curl http://127.0.0.1:9090/v1/server_info to get the info from server-info API): 3.4.0
  • apisix-dashboard version, if have: NA
  • the plugin runner version, if the issue is about a plugin runner (cmd: depended on the kind of runner):
  • luarocks version, if the issue is about installation (cmd: luarocks --version): 3.4.0

Steps to reproduce

as mentioned above, if we exceed the request count more than 10

Actual result

<title>429 Too Many Requests</title>

429 Too Many Requests


openresty

Error log

2021/09/21 13:57:03 [warn] 2926#2926: *85612 [lua] plugin.lua:658: run_plugin(): limit-count exits with http status code 429, client: 127.0.0.1, server: _, request: "GET /order/list?pageSize=10 HTTP/1.1", host: "127.0.0.1:9080"

Expected result

{"message":"Request Limit Exceeded"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions