Skip to content

fix: change default headers to empty table instead of an array to remove deprecation notice#174

Merged
ms2008 merged 6 commits intoKong:masterfrom
jijiechen:fix-deprecated-default-headers
Nov 19, 2025
Merged

fix: change default headers to empty table instead of an array to remove deprecation notice#174
ms2008 merged 6 commits intoKong:masterfrom
jijiechen:fix-deprecated-default-headers

Conversation

@jijiechen
Copy link
Copy Markdown
Member

The library deprecated usage of array headers on health check settings long ago in commit fae6e84 and it added a deprecation notice.

However, the headers field in default settings was left as an array { "" }, which causes all checks without explicit headers are triggering this deprecation notice.

if headers_length > 0 then
if is_array(req_headers) then
self:log(WARN, "array headers is deprecated")
headers = table_concat(req_headers, "\r\n")
else

This PR changes the default value to be an empty table instead of the default array. The new default value is well covered by existing test cases, so no need to add new ones.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Nov 17, 2025

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

tzssangglass
tzssangglass previously approved these changes Nov 17, 2025
zhikai-kong
zhikai-kong previously approved these changes Nov 18, 2025
Signed-off-by: Jay Chen <1180092+jijiechen@users.noreply.github.com>
@jijiechen jijiechen dismissed stale reviews from tzssangglass and zhikai-kong via 13a81b1 November 18, 2025 02:34
Comment thread lib/resty/healthcheck.lua
https_sni = NO_DEFAULT,
https_verify_certificate = true,
headers = {""},
headers = NO_DEFAULT_NON_NESTED,
Copy link
Copy Markdown
Member Author

@jijiechen jijiechen Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the actual modification that fixes the issue, it is still to change the default value of the headers from an array to a table.

However, the test failed by the first commit because the original code at function fill_in_settings treated arrays and non-array tables differently. This caused the table I modified yesterday to be treated as a "multi-level nested object", hence tables passed from external also process incorrectly, this ultimately causing all headers to be wiped.

if type(v) == "table" then
if default[1] then -- do not recurse on arrays
obj[k] = v
else

@jijiechen
Copy link
Copy Markdown
Member Author

The fix is ​​as follows:

  1. In the default values ​​of headers, use a special table NO_DEFAULT_NON_NESTED.
  2. When processing options in fill_in_settings, if NO_DEFAULT_NON_NESTED is seen, nested assignment is skipped, and since this value is a dummy placeholder, it is not assigned to the actual field.
  3. Before actually sending the health check request, if headers are not set externally, it defaults to an empty string (maintaining the original logic).

Comment thread lib/resty/healthcheck.lua
@ms2008 ms2008 merged commit 5120ade into Kong:master Nov 19, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants