fix: should assign value to api_ctx.global_rules before running global rules#3595
Conversation
|
Is this a bug? Which PR introduced it? |
|
|
||
| -- run global rule | ||
| plugin.run_global_rules(api_ctx, router.global_rules, "access") | ||
| api_ctx.global_rules = router.global_rules |
There was a problem hiding this comment.
Do it in run_global_rules?
Need to update the api_router.lua too
There was a problem hiding this comment.
@spacewander
Thanks for reviewing.
I still have some doubts. The original code also assign value to api_ctx.global_rules after run_plugin, but it does not cause a bug like this. .
There was a problem hiding this comment.
@spacewander
Thanks for reviewing.
I still have some doubts. The original code also assign value toapi_ctx.global_rulesafterrun_plugin, but it does not cause a bug like this. .
I re-checked the original code, it filtered plugins of global rule and assigned them to api_ctx.plugins, that is why..
yes, it's a bug. it's introduced by #3396 |
|
@nic-chen Could you tell me where we use |
| @@ -689,6 +689,10 @@ function _M.run_global_rules(api_ctx, global_rules, phase_name) | |||
| local orig_conf_version = api_ctx.conf_version | |||
There was a problem hiding this comment.
better style, we can fix it in a new PR
function _M.run_global_rules(api_ctx, global_rules, phase_name)
if not global_rules or not global_rules.values
and #global_rules.values == 0 then
return
end
-- your code
endThere was a problem hiding this comment.
better style, we can fix it in a new PR
function _M.run_global_rules(api_ctx, global_rules, phase_name) if not global_rules or not global_rules.values and #global_rules.values == 0 then return end -- your code end
OK
What this PR does / why we need it:
this bug introduced by #3396.
should assign value to
api_ctx.global_rulesbefore running global rules, otherwise if a plugin exits in the access phase, global rules will not be able to run in the subsequent phases.Pre-submission checklist: