Skip to content

fix(dns): correct error() call in dns client initialization#13358

Merged
AlinsRan merged 1 commit into
apache:masterfrom
suryaparua-official:fix/limit-count-clean
Jul 7, 2026
Merged

fix(dns): correct error() call in dns client initialization#13358
AlinsRan merged 1 commit into
apache:masterfrom
suryaparua-official:fix/limit-count-clean

Conversation

@suryaparua-official

Copy link
Copy Markdown
Contributor

Summary

Fixes #13357

Changes

In apisix/plugins/limit-count/init.lua at line 262, the error()
function was called with incorrect arguments:

-- Before (wrong)
error("failed to generate key invalid parent: ", core.json.encode(parent))

-- After (correct)
error("failed to generate key invalid parent: " .. core.json.encode(parent))

Lua's error(message, level) expects the second argument to be an
integer (stack level: 0, 1, or 2), not a string. The previous code
would cause LuaJIT to raise:

bad argument #2 to 'error' (number expected, got string)

Test

Added a test case in t/plugin/limit-count5.t to verify the error
message is correct when _meta.parent is missing.

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels May 12, 2026
Comment thread t/plugin/limit-count5.t Outdated
commit2: 0
peek4: 0
commit3: rejected

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we need three empty lines in between tests.

@hachi029

Copy link
Copy Markdown
Contributor

A similar error occurs in apisix/discovery/dns/init.lua:81

@suryaparua-official

Copy link
Copy Markdown
Contributor Author

Hi @hachi029, thank you for pointing that out! I will fix the similar issue in apisix/discovery/dns/init.lua:81 and include it in this PR.

Comment thread t/plugin/limit-count5.t Outdated
error()'s second argument is the level, not a message part, so the
original error("...: ", err) dropped err (or raised a bad-argument
error). Concatenate err into the message instead.
@AlinsRan AlinsRan force-pushed the fix/limit-count-clean branch from d032184 to b35aa23 Compare July 6, 2026 09:01
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jul 6, 2026
@AlinsRan AlinsRan changed the title fix(limit-count): correct error() call in gen_limit_key fix(dns): correct error() call in dns client initialization Jul 6, 2026

@membphis membphis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@AlinsRan AlinsRan merged commit 333f46a into apache:master Jul 7, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(limit-count): incorrect error() call in gen_limit_key passes string as level argument

6 participants