Kong / Kong/lua-resty-aws

Input is not valid error when I call POST API

Open
#101 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Lua
Stars
35
Forks
28
PR merge metrics
No merged PRs in 30d

Description

I encountered an issue when calling the API of cloudfront. I called a POST API and got a 400 http error code. I print the log of request body in the execute.lua:
```


cdn_test



GET
POST

2

false
600


*

1

true


*

1





true
rcy
name


1

```
And the response body returned by AWS server:
```


Sender
MalformedInput
input is not valid, expected ResponseHeadersPolicyConfig

cd10f090-22eb-41b3-94df-4264f9d45402

```
Then I checked the AWS REST API [document](https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_CreateResponseHeadersPolicy.html), just found that request body shouldn't have the root `input` tag.
The `input` tag come from the raw-api api-description files. After I changed the code to remove the input tag, the call succeed.
```
build.lua#232
-- encode rest of the body data here
-- poor_mans_xml_encoding(xml_data, operation.input, "input", body_tbl)

for name, member in pairs(operation.input.members) do
if body_tbl[name] then
poor_mans_xml_encoding(xml_data, member, name, body_tbl[name], 0)
end
end
```
But I'm not sure if I missed something else.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at build.lua#232 and inspect how the raw-api description supplies operation.input when creating the CloudFront CreateResponseHeadersPolicy request. Reproduce the POST request, compare the generated XML with the AWS API documentation, and confirm that the corrected request succeeds without the unwanted root input tag.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, lua
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.