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

fix(limit-count): conf with group and disable can't be configured #7384

Merged
merged 3 commits into from
Jul 7, 2022

Conversation

soulbird
Copy link
Contributor

@soulbird soulbird commented Jul 5, 2022

Description

Fixes #7375

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@soulbird soulbird marked this pull request as ready for review July 5, 2022 05:20
Copy link
Member

@spacewander spacewander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local fields = {}
for k in pairs(schema.properties) do
tab_insert(fields, k)
end
local extra = policy_to_additional_properties[conf.policy]
if extra then
for k in pairs(extra.properties) do
tab_insert(fields, k)
end
end
local prev_conf = group_conf_lru(conf.group, "", group_conf, conf)
for _, field in ipairs(fields) do
if not core.table.deep_eq(prev_conf[field], conf[field]) then
core.log.error("previous limit-conn group ", prev_conf.group,

We use a whitelist for the fields which need to be compared, and disable is expected not in the list?

@soulbird
Copy link
Contributor Author

soulbird commented Jul 5, 2022

local fields = {}
for k in pairs(schema.properties) do
tab_insert(fields, k)
end
local extra = policy_to_additional_properties[conf.policy]
if extra then
for k in pairs(extra.properties) do
tab_insert(fields, k)
end
end
local prev_conf = group_conf_lru(conf.group, "", group_conf, conf)
for _, field in ipairs(fields) do
if not core.table.deep_eq(prev_conf[field], conf[field]) then
core.log.error("previous limit-conn group ", prev_conf.group,

We use a whitelist for the fields which need to be compared, and disable is expected not in the list?

Yes, it's injected in: https://github.com/apache/apisix/blob/master/apisix/plugin.lua#L139-L162

@soulbird
Copy link
Contributor Author

soulbird commented Jul 6, 2022

The whitelist for the fields does not work as it should, because the schema may be injected into other fields, currently there are disable _meta $comment. A better approach is to move all injected fields into _meta and manually filter out this field in the whitelist. But this would introduce a break change, not sure if it's worth it. cc @spacewander

@spacewander spacewander merged commit dbd78df into apache:master Jul 7, 2022
spacewander pushed a commit to spacewander/incubator-apisix that referenced this pull request Aug 17, 2022
Liu-Junlin pushed a commit to Liu-Junlin/apisix that referenced this pull request Nov 4, 2022
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

Successfully merging this pull request may close these issues.

bug: limit-count plugin,"group" peoperty result in 404 code
3 participants