Assumption KONG_ACCESS_START will always be set in tx context.
jeremyjpj0916 opened this issue · 1 comments
jeremyjpj0916 commented
Hit a tx that was blocked by the Mod Security NGINX WAF returning a 400 to the client. The Log phase Zipkin execution assumed that KONG_ACCESS_START would be set in such a case when it must not get set in these cases. Other NGINX modules may do so as well due to short circuit. I supposed when Kong short circuits via access blocking etc auth plugins/acl plugins. the KONG_ACCESS_START is set.
2020/02/13 09:19:20 [error] 72#0: *37331 failed to run log_by_lua*: ...arocks/share/lua/5.1/kong/plugins/zipkin/opentracing.lua:208: attempt to perform arithmetic on field 'KONG_ACCESS_START' (a nil value)
--
| stack traceback:
| ...arocks/share/lua/5.1/kong/plugins/zipkin/opentracing.lua:208: in function 'log'
| ...g/luarocks/share/lua/5.1/kong/plugins/zipkin/handler.lua:34: in function <...g/luarocks/share/lua/5.1/kong/plugins/zipkin/handler.lua:33>
| /usr/local/kong/luarocks/share/lua/5.1/kong/init.lua:209: in function 'execute_plugins_iterator'
| /usr/local/kong/luarocks/share/lua/5.1/kong/init.lua:1068: in function 'log'
| log_by_lua(nginx.conf:167):2: in main chunk while logging request, client: 10.96.29.29, server: kong, request: "GET /api/pdr/demo/test/v1.0?appealid=13414&trackingid=518sourcesystem=ETS HTTP/1.1", host: "gateway.company.com"
Might be worth considering the case that it's not set though to prevent NPE's. Generally preventing nil pointers in app execution is good anyways with proper checking in place due to 3rd party modules and integrations.
hishamhm commented
Thanks @jeremyjpj0916 ! We'll look into it!