fix(core): reduce uninitialized variable message when nginx return 400
Summary
When Kong receives abnormal traffic, it will trigger 400 responses without initializing any Nginx variable, So it will trigger report.lua error, which is unnecessary.
eg: send HTTP traffic to HTTPS port, Nginx will finalize the current request by 400 response in the TLS handshake, So it will never call any openresty HTTP processing phase, it also does not initialize any Nginx variable.
Checklist
- [x] The Pull Request has tests
- [x] A changelog file has been created under
changelog/unreleased/kongorskip-changeloglabel added on PR if changelog is unnecessary. README.md - [ ] There is a user-facing docs PR against https://github.com/Kong/docs.konghq.com - PUT DOCS PR HERE
Issue reference
Fix https://github.com/Kong/kong/issues/13197 https://konghq.atlassian.net/browse/FTI-6025
@oowl, did we consider defining those variables? E.g. move them to upper scope or something? Or skipping accessing them when we know they are not there (currently it feels like only reports.lua has this issue, so turning totally off feel like hitting a fly with a hammer)? Uninitialized warnings seems to be nice thing to catch some small issues? So turning it totally off feels like we will also miss something.
I have tried to place set command to the main block, but it did not resolve this problem. https://github.com/Kong/kong/pull/13201/commits/50d6c66e0b02e9c2fedf3ab54158a2a89f37db80
I think the problem is nginx can not get the location in the SSL handshake phase, it has no chance to init any variable. @bungle