You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "hachi029 (via GitHub)" <gi...@apache.org> on 2025/03/13 12:40:09 UTC

[PR] fix: plugins repeats the rewrite phase when consumer configs with a p… [apisix]

hachi029 opened a new pull request, #12048:
URL: https://github.com/apache/apisix/pull/12048

   …lugin
   
   ### Description
   plugins repeats the rewrite phase when consumer configs with a plugin.  
   
   
   Fixes # (issue)
   
    #10945 #10873
   
   ### 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](https://github.com/apache/apisix/tree/master#community) first)
   
   <!--
   
   Note
   
   1. Mark the PR as draft until it's ready to be reviewed.
   2. Always add/update tests for any changes unless you have a good reason.
   3. Always update the documentation to reflect the changes made in the PR.
   4. Make a new commit to resolve conversations instead of `push -f`.
   5. To resolve merge conflicts, merge master instead of rebasing.
   6. Use "request review" to notify the reviewer after making changes.
   7. Only a reviewer can mark a conversation as resolved.
   
   -->
   


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: plugins repeats the rewrite phase when consumer configs with a p… [apisix]

Posted by "nic-6443 (via GitHub)" <gi...@apache.org>.
nic-6443 commented on code in PR #12048:
URL: https://github.com/apache/apisix/pull/12048#discussion_r2009812263


##########
apisix/plugin.lua:
##########
@@ -506,6 +506,16 @@ function _M.filter(ctx, conf, plugins, route_conf, phase)
             if plugin_conf._meta and plugin_conf._meta.priority then
                 custom_sort = true
             end
+

Review Comment:
   how about move this check to 
   https://github.com/apache/apisix/blob/52d8fea3dbc93c4b59ac6682902955c6146af4ad/apisix/plugin.lua#L1184-L1186
   as 
   ```
   if plugins[i].type == "auth" or (not plugins[i + 1]._from_consumer) then
       plugins[i + 1]._skip_rewrite_in_consumer = true
   end
   ```
   so that we can keep skip logic in one place.



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: plugins repeats the rewrite phase when consumer configs with a p… [apisix]

Posted by "hachi029 (via GitHub)" <gi...@apache.org>.
hachi029 commented on code in PR #12048:
URL: https://github.com/apache/apisix/pull/12048#discussion_r2010185654


##########
apisix/plugin.lua:
##########
@@ -506,6 +506,16 @@ function _M.filter(ctx, conf, plugins, route_conf, phase)
             if plugin_conf._meta and plugin_conf._meta.priority then
                 custom_sort = true
             end
+

Review Comment:
   Ok. Is it better move  
   ```
   if plugins[i].type == "auth" then
       plugins[i + 1]._skip_rewrite_in_consumer = true
   end
   ```
   into _M.filter(...) ?  Because it is the function _M.filter determines or marks whether a plugin will be executed or not . 



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: plugins repeats the rewrite phase when consumer configs with a p… [apisix]

Posted by "nic-6443 (via GitHub)" <gi...@apache.org>.
nic-6443 commented on code in PR #12048:
URL: https://github.com/apache/apisix/pull/12048#discussion_r2011253938


##########
apisix/plugin.lua:
##########
@@ -506,6 +506,16 @@ function _M.filter(ctx, conf, plugins, route_conf, phase)
             if plugin_conf._meta and plugin_conf._meta.priority then
                 custom_sort = true
             end
+

Review Comment:
   I found that there is a place where the `run_plugin` function is executed without executing `filter` first: https://github.com/apache/apisix/blob/52d8fea3dbc93c4b59ac6682902955c6146af4ad/apisix/init.lua#L437-L451
   so I am not sure if moving it to `filter` will cause any issues.



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: plugins repeats the rewrite phase when consumer configs with a p… [apisix]

Posted by "hachi029 (via GitHub)" <gi...@apache.org>.
hachi029 commented on code in PR #12048:
URL: https://github.com/apache/apisix/pull/12048#discussion_r2010185654


##########
apisix/plugin.lua:
##########
@@ -506,6 +506,16 @@ function _M.filter(ctx, conf, plugins, route_conf, phase)
             if plugin_conf._meta and plugin_conf._meta.priority then
                 custom_sort = true
             end
+

Review Comment:
   Ok. Is it better move  
   ```
           if plugins[i].type == "auth" then
               plugins[i + 1]._skip_rewrite_in_consumer = true
           end
   ```
   into _M.filter(...) ? because it is the function _M.filter determines or marks whether a plugin will be executed or not . 



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: plugins repeats the rewrite phase when consumer configs with a p… [apisix]

Posted by "hachi029 (via GitHub)" <gi...@apache.org>.
hachi029 commented on code in PR #12048:
URL: https://github.com/apache/apisix/pull/12048#discussion_r2010185654


##########
apisix/plugin.lua:
##########
@@ -506,6 +506,16 @@ function _M.filter(ctx, conf, plugins, route_conf, phase)
             if plugin_conf._meta and plugin_conf._meta.priority then
                 custom_sort = true
             end
+

Review Comment:
   Ok. Is it better to move  
   ```
   if plugins[i].type == "auth" then
       plugins[i + 1]._skip_rewrite_in_consumer = true
   end
   ```
   into _M.filter(...) ?  Because it is the function _M.filter that determines or marks whether a plugin will be executed or not . 



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: plugins repeats the rewrite phase when consumer configs with a p… [apisix]

Posted by "hachi029 (via GitHub)" <gi...@apache.org>.
hachi029 commented on code in PR #12048:
URL: https://github.com/apache/apisix/pull/12048#discussion_r2011414662


##########
apisix/plugin.lua:
##########
@@ -506,6 +506,16 @@ function _M.filter(ctx, conf, plugins, route_conf, phase)
             if plugin_conf._meta and plugin_conf._meta.priority then
                 custom_sort = true
             end
+

Review Comment:
    these modifications only affect the 'rewrite_in_consumer' phase.



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: plugins repeats the rewrite phase when consumer configs with a p… [apisix]

Posted by "hachi029 (via GitHub)" <gi...@apache.org>.
hachi029 commented on code in PR #12048:
URL: https://github.com/apache/apisix/pull/12048#discussion_r2010185654


##########
apisix/plugin.lua:
##########
@@ -506,6 +506,16 @@ function _M.filter(ctx, conf, plugins, route_conf, phase)
             if plugin_conf._meta and plugin_conf._meta.priority then
                 custom_sort = true
             end
+

Review Comment:
   Ok. Is it better move  
   ```
       if plugins[i].type == "auth" then
           plugins[i + 1]._skip_rewrite_in_consumer = true
       end
   ```
   into _M.filter(...) ? because it is the function _M.filter determines or marks whether a plugin will be executed or not . 



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: plugins repeats the rewrite phase when consumer configs with a p… [apisix]

Posted by "hachi029 (via GitHub)" <gi...@apache.org>.
hachi029 commented on code in PR #12048:
URL: https://github.com/apache/apisix/pull/12048#discussion_r2011414662


##########
apisix/plugin.lua:
##########
@@ -506,6 +506,16 @@ function _M.filter(ctx, conf, plugins, route_conf, phase)
             if plugin_conf._meta and plugin_conf._meta.priority then
                 custom_sort = true
             end
+

Review Comment:
   @nic-6443  these modifications only affect the `rewrite_in_consumer` phase.



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: plugins repeats the rewrite phase when consumer configs with a plugin [apisix]

Posted by "Baoyuantop (via GitHub)" <gi...@apache.org>.
Baoyuantop merged PR #12048:
URL: https://github.com/apache/apisix/pull/12048


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: plugins repeats the rewrite phase when consumer configs with a p… [apisix]

Posted by "hachi029 (via GitHub)" <gi...@apache.org>.
hachi029 commented on code in PR #12048:
URL: https://github.com/apache/apisix/pull/12048#discussion_r2010185654


##########
apisix/plugin.lua:
##########
@@ -506,6 +506,16 @@ function _M.filter(ctx, conf, plugins, route_conf, phase)
             if plugin_conf._meta and plugin_conf._meta.priority then
                 custom_sort = true
             end
+

Review Comment:
   Ok. Is it better move  
   ```
   if plugins[i].type == "auth" then
       plugins[i + 1]._skip_rewrite_in_consumer = true
   end
   ```
   into _M.filter(...) ? because it is the function _M.filter determines or marks whether a plugin will be executed or not . 



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix: plugins repeats the rewrite phase when consumer configs with a plugin [apisix]

Posted by "membphis (via GitHub)" <gi...@apache.org>.
membphis commented on code in PR #12048:
URL: https://github.com/apache/apisix/pull/12048#discussion_r2025879879


##########
t/node/plugin1.t:
##########
@@ -0,0 +1,104 @@
+#

Review Comment:
   You can make a try, give this file a meaningful name



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org