You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the OPA plugin with "with_route" set to true an error is thrown by APISIX which returns a 500 error code.
Expected Behavior
When using the OPA plugin with "with_route" set to true, the policy related to the route would receive information about the route, validate the the input against the policy and if the policy allows the request, the request would be proxied to the upstream.
Error Logs
2023-11-07 17:35:37 2023/11/07 15:35:37 [error] 267#267: *4727521 lua entry thread aborted: runtime error: /usr/local/apisix/apisix/init.lua:244: attempt to index field 'upstream' (a nil value)
2023-11-07 17:35:37 stack traceback:
2023-11-07 17:35:37 coroutine 0:
2023-11-07 17:35:37 /usr/local/apisix/apisix/init.lua: in function 'parse_domain_in_route'
2023-11-07 17:35:37 /usr/local/apisix/apisix/init.lua:496: in function 'handle_upstream'
2023-11-07 17:35:37 /usr/local/apisix/apisix/init.lua:730: in function 'http_access_phase'
2023-11-07 17:35:37 access_by_lua(nginx.conf:301):2: in main chunk, client: 172.18.0.1, server: _, request: "GET /products HTTP/1.1", host: "127.0.0.1:9080"
Call Route B via a POST request to reproduce the error
The issue seems to occur here :
local function build_http_route(conf, ctx, remove_upstream)
local route = core.table.clone(ctx.matched_route).value
if remove_upstream and route and route.upstream then
route.upstream = nil
end
return route
end
What should local route = core.table.clone(ctx.matched_route).value be not to change the route ctx ?
WrightKD
changed the title
bug: OPA Plugin with the attribute "with_route" set to true cases a 500 status error
bug: OPA Plugin with the attribute "with_route" set to true causes a 500 status error
Nov 12, 2023
Current Behavior
When using the OPA plugin with "with_route" set to true an error is thrown by APISIX which returns a 500 error code.
Expected Behavior
When using the OPA plugin with "with_route" set to true, the policy related to the route would receive information about the route, validate the the input against the policy and if the policy allows the request, the request would be proxied to the upstream.
Error Logs
2023-11-07 17:35:37 2023/11/07 15:35:37 [error] 267#267: *4727521 lua entry thread aborted: runtime error: /usr/local/apisix/apisix/init.lua:244: attempt to index field 'upstream' (a nil value)
2023-11-07 17:35:37 stack traceback:
2023-11-07 17:35:37 coroutine 0:
2023-11-07 17:35:37 /usr/local/apisix/apisix/init.lua: in function 'parse_domain_in_route'
2023-11-07 17:35:37 /usr/local/apisix/apisix/init.lua:496: in function 'handle_upstream'
2023-11-07 17:35:37 /usr/local/apisix/apisix/init.lua:730: in function 'http_access_phase'
2023-11-07 17:35:37 access_by_lua(nginx.conf:301):2: in main chunk, client: 172.18.0.1, server: _, request: "GET /products HTTP/1.1", host: "127.0.0.1:9080"
Steps to Reproduce
Example Route that works fine without OPA (Route A)
Example Route that fails with OPA (Route B)
The issue seems to occur here :
What should
local route = core.table.clone(ctx.matched_route).value
be not to change the route ctx ?Environment
versions from curl -sL https://run.api7.ai/apisix/quickstart | sh
The text was updated successfully, but these errors were encountered: