fix(workflow): skip the action plugin in the chain to avoid double execution#13617
Merged
shreemaan-abhishek merged 2 commits intoJun 30, 2026
Conversation
…ecution When a plugin such as limit-count or limit-conn runs as a workflow action and the same plugin is also configured in the normal plugin chain, the plugin runs twice per request (e.g. a request is counted twice against a rate limit). Mark the action plugin as skipped for the rest of the request so it does not run again in the chain. Signed-off-by: shreemaan-abhishek <shreemaan.abhishek@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR addresses a real double-execution problem when workflow runs a plugin as an action and the same plugin is also present in the normal plugin chain, by introducing a per-request “skip this plugin” mechanism to prevent the second execution.
Changes:
- Add
plugin.skip_plugin(ctx, name)and honor the skip list insideplugin.run_pluginloops to prevent double execution. - Update
workflowplugin to mark the action plugin as skipped for the remainder of the request. - Add regression coverage to ensure
limit-countis only applied once when used both in the chain and as a workflow action, and document the behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| t/plugin/workflow-without-case.t | Adds a test scenario proving the action plugin is skipped in the normal chain to avoid double counting. |
| docs/en/latest/plugins/workflow.md | Documents that action plugins are skipped in the normal chain for that request to prevent double execution. |
| apisix/plugins/workflow.lua | Calls plugin.skip_plugin(ctx, action[1]) before executing the action handler. |
| apisix/plugin.lua | Introduces skip_plugin and checks _skip_plugins during plugin execution loops. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Move the _skip_plugins check above run_meta_pre_function and the _plugin_name assignment so a plugin run as a workflow action does not fire its meta pre_function again, does not set plugin_run, and leaves no stale _plugin_name. Signed-off-by: shreemaan-abhishek <shreemaan.abhishek@gmail.com>
membphis
approved these changes
Jun 29, 2026
nic-6443
approved these changes
Jun 30, 2026
AlinsRan
approved these changes
Jun 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The
workflowPlugin (priority 1006) can run a plugin such aslimit-count(priority 1002) orlimit-conn(priority 1003) as an action. When the same plugin is also configured directly in the normal plugin chain on the same Route/Service/Consumer/Global Rule, the plugin ends up running twice per request:workflowaction handler, andworkflowaccess handler returnsnilon the non-rejected path, so it does not short-circuit the chain).The visible impact is that a request is counted/limited twice. For
limit-countthe quota is consumed at 2x; the same applies tolimit-conn(which is also double-counted in bothaccessandlog). This is reachable with stock plugins and a non-exotic configuration.This PR adds
plugin.skip_plugin(ctx, name)to mark the action plugin as skipped for the rest of the request, so onceworkflowruns it as an action it is not executed again in the normal chain. The skip is honored in bothrun_pluginloops (access/rewrite and log/header_filter/body_filter), solimit-conn'slog-phase decrement is also handled only by theworkflowaction.Which issue(s) this PR fixes:
N/A
Checklist