fix(limit-count): correct error() call in gen_limit_key#13358
Open
suryaparua-official wants to merge 1 commit into
Open
fix(limit-count): correct error() call in gen_limit_key#13358suryaparua-official wants to merge 1 commit into
suryaparua-official wants to merge 1 commit into
Conversation
The second argument to Lua's error(msg, level) must be an integer (stack level), not a string. Passing core.json.encode(parent) as the level causes LuaJIT to raise: bad argument apache#2 to error (number expected, got string) Fix: concatenate the JSON into the message string using '..'. Also add a test case to verify the error message is correct when _meta.parent is missing. Fixes apache#13357
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #13357
Changes
In
apisix/plugins/limit-count/init.luaat line 262, theerror()function was called with incorrect arguments:
Lua's
error(message, level)expects the second argument to be aninteger (stack level: 0, 1, or 2), not a string. The previous code
would cause LuaJIT to raise:
Test
Added a test case in
t/plugin/limit-count5.tto verify the errormessage is correct when
_meta.parentis missing.