Skip to content
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

fix(aws-lambda) Fix typo in X-Amz-Function-Error header #2676

Merged
merged 1 commit into from
Jul 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kong/plugins/aws-lambda/handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function AWSLambdaHandler:access(conf)
end

if conf.unhandled_status
and headers["X-Amzn-Function-Error"] == "Unhandled"
and headers["X-Amz-Function-Error"] == "Unhandled"
then
ngx.status = conf.unhandled_status

Expand Down
10 changes: 5 additions & 5 deletions spec/03-plugins/23-aws-lambda/01-access_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ describe("Plugin: AWS Lambda (access)", function()
local body = assert.res_status(200, res)
assert.is_string(res.headers["x-amzn-RequestId"])
assert.equal([["some_value1"]], body)
assert.is_nil(res.headers["X-Amzn-Function-Error"])
assert.is_nil(res.headers["X-Amz-Function-Error"])
end)
it("invokes a Lambda function with POST params", function()
local res = assert(client:send {
Expand Down Expand Up @@ -293,7 +293,7 @@ describe("Plugin: AWS Lambda (access)", function()
}
})
assert.res_status(200, res)
assert.equal("Unhandled", res.headers["X-Amzn-Function-Error"])
assert.equal("Unhandled", res.headers["X-Amz-Function-Error"])
end)
it("invokes a Lambda function with an unhandled function error with Event invocation type", function()
local res = assert(client:send {
Expand All @@ -304,7 +304,7 @@ describe("Plugin: AWS Lambda (access)", function()
}
})
assert.res_status(202, res)
assert.equal("Unhandled", res.headers["X-Amzn-Function-Error"])
assert.equal("Unhandled", res.headers["X-Amz-Function-Error"])
end)
it("invokes a Lambda function with an unhandled function error with DryRun invocation type", function()
local res = assert(client:send {
Expand All @@ -315,7 +315,7 @@ describe("Plugin: AWS Lambda (access)", function()
}
})
assert.res_status(204, res)
assert.equal("Unhandled", res.headers["X-Amzn-Function-Error"])
assert.equal("Unhandled", res.headers["X-Amz-Function-Error"])
end)
it("invokes a Lambda function with an unhandled function error", function()
local res = assert(client:send {
Expand All @@ -326,6 +326,6 @@ describe("Plugin: AWS Lambda (access)", function()
}
})
assert.res_status(412, res)
assert.equal("Unhandled", res.headers["X-Amzn-Function-Error"])
assert.equal("Unhandled", res.headers["X-Amz-Function-Error"])
end)
end)
2 changes: 1 addition & 1 deletion spec/fixtures/custom_nginx.template
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ http {
local function say(res, status)
ngx.header["x-amzn-RequestId"] = "foo"
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to use the same prefix as well here? X-Amz-RequestId?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@thibaultcha this is actually correct based on the response from Lambda (you can see the response headers in my original issue comment).

Copy link
Member

Choose a reason for hiding this comment

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

Interesting... They have different response headers prefixes then... 🤔 LGTM then!

if string.match(ngx.var.uri, "functionWithUnhandledError") then
ngx.header["X-Amzn-Function-Error"] = "Unhandled"
ngx.header["X-Amz-Function-Error"] = "Unhandled"
end
ngx.status = status

Expand Down