membphis commented on code in PR #13019:
URL: https://github.com/apache/apisix/pull/13019#discussion_r2850484619
##########
apisix/plugins/limit-req.lua:
##########
@@ -122,6 +123,20 @@ local function create_limit_obj(conf)
end
+local function gen_limit_key(conf, ctx, key)
+ local parent = conf._meta and conf._meta.parent
+ if not parent or not parent.resource_key then
+ core.log.error("failed to generate key invalid parent: ",
core.json.encode(parent))
Review Comment:
we can call `error`, throw a panic error
it should never happen
##########
apisix/plugins/limit-req.lua:
##########
@@ -122,6 +123,20 @@ local function create_limit_obj(conf)
end
+local function gen_limit_key(conf, ctx, key)
+ local parent = conf._meta and conf._meta.parent
+ if not parent or not parent.resource_key then
+ core.log.error("failed to generate key invalid parent: ",
core.json.encode(parent))
+ return nil
+ end
+
+ local new_key = parent.resource_key .. ':' ..
apisix_plugin.conf_version(conf)
Review Comment:
```suggestion
return parent.resource_key .. ':' .. apisix_plugin.conf_version(conf) ..
':' .. key
```
##########
apisix/plugins/limit-req.lua:
##########
@@ -122,6 +123,20 @@ local function create_limit_obj(conf)
end
+local function gen_limit_key(conf, ctx, key)
+ local parent = conf._meta and conf._meta.parent
+ if not parent or not parent.resource_key then
+ core.log.error("failed to generate key invalid parent: ",
core.json.encode(parent))
Review Comment:
if you copied those code from plugin `limit-count`
welcome to submit a new PR, fix it too
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]