check why data session is nil in header but availablein body

This commit is contained in:
wiaamm
2025-12-07 15:07:23 +02:00
parent e183e8fa02
commit 75f543f971

View File

@@ -161,6 +161,8 @@ end
function NanoHandler.header_filter(conf) function NanoHandler.header_filter(conf)
local ctx = kong.ctx.plugin local ctx = kong.ctx.plugin
kong.log.err("header_filter: ctx.blocked=", ctx.blocked, " ctx.cleanup_needed=", ctx.cleanup_needed, " ctx.session_id=", ctx.session_id, " ctx.session_data=", ctx.session_data and "EXISTS" or "NIL")
if ctx.blocked or ctx.cleanup_needed then if ctx.blocked or ctx.cleanup_needed then
return return
end end
@@ -169,7 +171,7 @@ function NanoHandler.header_filter(conf)
local session_data = ctx.session_data local session_data = ctx.session_data
if not session_id or not session_data then if not session_id or not session_data then
kong.log.err("No session data found in header_filter") kong.log.err("No session data found in header_filter - session_id:", session_id, " session_data:", session_data)
return return
end end
@@ -199,8 +201,10 @@ function NanoHandler.body_filter(conf)
local chunk = ngx.arg[1] local chunk = ngx.arg[1]
local eof = ngx.arg[2] local eof = ngx.arg[2]
kong.log.err("body_filter START: ctx.blocked=", ctx.blocked, " ctx.cleanup_needed=", ctx.cleanup_needed, " ctx.session_id=", ctx.session_id, " ctx.session_data=", ctx.session_data and "EXISTS" or "NIL")
if ctx.blocked or ctx.cleanup_needed then if ctx.blocked or ctx.cleanup_needed then
kong.log.err("Fail-open mode - blocked chunk without inspection, chunk size: ", chunk and #chunk or 0) kong.log.err("Fail-open mode - blocked/cleanup chunk without inspection, chunk size: ", chunk and #chunk or 0)
if chunk then if chunk then
ngx.arg[1] = chunk ngx.arg[1] = chunk
@@ -211,7 +215,7 @@ function NanoHandler.body_filter(conf)
kong.log.err("In body_filter phase") kong.log.err("In body_filter phase")
local session_id = ctx.session_id local session_id = ctx.session_id
local session_data = ctx.session_data local session_data = ctx.session_data
kong.log.err("Session id after") kong.log.err("Session id after: ", session_id, " session_data: ", session_data and "EXISTS" or "NIL")
if not session_id or not session_data or ctx.session_finalized then if not session_id or not session_data or ctx.session_finalized then
kong.log.err("Fail-open mode - consuming chunk without inspection, chunk size: ", chunk and #chunk or 0) kong.log.err("Fail-open mode - consuming chunk without inspection, chunk size: ", chunk and #chunk or 0)
-- In fail-open, we need to consume the chunk to prevent buffering -- In fail-open, we need to consume the chunk to prevent buffering