Skip to content

Conversation

@shreemaan-abhishek
Copy link
Contributor

@shreemaan-abhishek shreemaan-abhishek commented Dec 8, 2025

Description

When the same plugin is configured across different global rules, there will be no guarantee on which plugin config will be executed first. Additionally, the current architecture does not guarantee plugin execution order according to the priority.

We address this problem by disallowing configuring same plugin across multiple global_rules and sorting the plugins to their priority and executing in order.

Fixes: #12704

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)

Signed-off-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. plugin labels Dec 8, 2025
Signed-off-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Dec 9, 2025
Signed-off-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
Signed-off-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
Signed-off-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
nic-6443
nic-6443 previously approved these changes Dec 9, 2025
membphis
membphis previously approved these changes Dec 12, 2025
@Baoyuantop Baoyuantop linked an issue Dec 15, 2025 that may be closed by this pull request
Signed-off-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
@shreemaan-abhishek shreemaan-abhishek dismissed stale reviews from membphis and nic-6443 via 4df44ed December 16, 2025 07:02
Signed-off-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>

-- remove duplicate plugins
for plugin_name, _ in pairs(duplicate_plugins) do
all_plugins[plugin_name] = nil
Copy link
Contributor

Choose a reason for hiding this comment

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

We should warn which plugins are not working.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you are right, thanks. I pushed a new commit that contains:

        core.log.warn("found ", plugin_name, " configured across different global rules ",
                      " it won't get executed")

Copy link
Contributor

Choose a reason for hiding this comment

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

I think duplicate_plugins are redundant.
Can we merge three loops into one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Signed-off-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
Signed-off-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
Signed-off-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
bzp2010
bzp2010 previously approved these changes Dec 19, 2025
AlinsRan
AlinsRan previously approved these changes Dec 19, 2025
nic-6443
nic-6443 previously approved these changes Dec 19, 2025
Signed-off-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
Signed-off-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
This reverts commit 6313730.
This reverts commit 0e6c6ce.
@membphis
Copy link
Member

lots of CI failed

f
Signed-off-by: Nic <qianyong@api7.ai>
@nic-6443 nic-6443 changed the title change: disallow creating duplicate plugins in global rules fix: disallow creating duplicate plugins in global rules Jan 6, 2026
nic-6443
nic-6443 previously approved these changes Jan 7, 2026
if global_rule.value and global_rule.value.plugins then
for plugin_name, plugin_conf in pairs(global_rule.value.plugins) do
if seen_plugin[plugin_name] then
core.log.warn("Found ", plugin_name,
Copy link
Member

Choose a reason for hiding this comment

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

we should use error log level

Copy link
Member

Choose a reason for hiding this comment

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

it is an important error message

Copy link
Member

Choose a reason for hiding this comment

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

if we used one plugin about 3 or 5 times

we should throw an error in this case

current way seems wrong

Signed-off-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
@shreemaan-abhishek shreemaan-abhishek merged commit 3af5759 into apache:master Jan 8, 2026
30 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugin size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: wrong plugin execution order

6 participants