-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(plugin/aws-lambda)accept string type statusCode as return when working in proxy integration mode #8765
Conversation
…orking in proxy integration mode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 First PR!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@dndx Could you review the PR again? Thanks! |
kong/plugins/aws-lambda/handler.lua
Outdated
if not status_code then | ||
return false | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be moved inside the if
block above, if the status_code
is not string
then there is no reason to check it again here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
I wonder if it needs more strict check on types, like
if type(status_code) == "string" or type(status_code) == "number" then
status_code = tonumber(status_code)
if not status_code then
return false
end
else
-- Validation failed if status code is not string or number
return false
end
end
Summary
Hi, I would like to add some compatibility to Kong's
aws-lambda
plugin so that it can receive string type status code when working in the proxy integration mode.When AWS Lambda function is working as a proxy integration, the
statusCode
returned by lambda function will become the HTTP status code returned by API gateway.Currently, we only accept number type
statusCode
,kong/kong/plugins/aws-lambda/handler.lua
Line 75 in 23f50ea
After some tests I found that AWS API gateway works fine if the type of
statusCode
is either number or string. And if thestatusCode
is an invalid HTTP status code, such as600
(smaller than 100 or larger than 599) or200a
(containing non-numeric characters), it will throw an "internal server error".It would be good for us to be compatible with a string type status code, according to FTI-4014.
Full changelog
statusCode
statusCode
is legalIssue reference
Fix FTI-4014