Skip to content

bug: 'global_rule' is a boolean value #1473

@membphis

Description

@membphis

Steps to reproduce:

  1. Add global routes (such as prometheus)
  2. Delete some global routes
  3. User request, we can see the response 500 error.

One photo from community:

image

This patch should be fine, and we need to add test case for confirming.

[proxychains] DLL init
diff --git a/apisix/init.lua b/apisix/init.lua
index aa8598e8..1e6b1efb 100644
--- a/apisix/init.lua
+++ b/apisix/init.lua
@@ -264,14 +264,16 @@ function _M.http_access_phase()
        and #router.global_rules.values > 0 then
         local plugins = core.tablepool.fetch("plugins", 32, 0)
         for _, global_rule in ipairs(router.global_rules.values) do
-            api_ctx.conf_type = "global_rule"
-            api_ctx.conf_version = global_rule.modifiedIndex
-            api_ctx.conf_id = global_rule.value.id
-
-            core.table.clear(plugins)
-            api_ctx.plugins = plugin.filter(global_rule, plugins)
-            run_plugin("rewrite", plugins, api_ctx)
-            run_plugin("access", plugins, api_ctx)
+            if type(global_rule) == "table" then
+                api_ctx.conf_type = "global_rule"
+                api_ctx.conf_version = global_rule.modifiedIndex
+                api_ctx.conf_id = global_rule.value.id
+
+                core.table.clear(plugins)
+                api_ctx.plugins = plugin.filter(global_rule, plugins)
+                run_plugin("rewrite", plugins, api_ctx)
+                run_plugin("access", plugins, api_ctx)
+            end
         end

         core.tablepool.release("plugins", plugins)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions