Skip to content

Commit

Permalink
fix(request): anticipate operations with no inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Tieske committed Mar 19, 2024
1 parent f6a4468 commit a47ea82
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ Release process:
- feat: container credential provider now supports using auth token defined in
AWS_CONTAINER_AUTHORIZATION_TOKEN and AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE.
[107](https://github.com/Kong/lua-resty-aws/pull/107)
- fix: operations without inputs (eg, some S3 ones) would cause errors to be thrown
[108](https://github.com/Kong/lua-resty-aws/pull/108)

### 1.3.6 (25-Dec-2023)

Expand Down
11 changes: 7 additions & 4 deletions src/resty/aws/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,16 @@ local function generate_service_methods(service)
method_name)

service[method_name] = function(self, params)
params = params or {}

--print(require("pl.pretty").write(self.config))

-- validate parameters
local ok, err = validate_input(params, operation.input, "params")
if not ok then
return nil, operation_prefix .. " validation error: " .. tostring(err)
-- validate parameters if we have any; eg. S3 "listBuckets" has none
if operation.input then
local ok, err = validate_input(params, operation.input, "params")
if not ok then
return nil, operation_prefix .. " validation error: " .. tostring(err)
end
end

-- implement stsRegionalEndpoints config setting,
Expand Down
2 changes: 1 addition & 1 deletion src/resty/aws/request/build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ local function build_request(operation, config, params)

-- inject parameters in the right places; path/query/header/body
-- this assumes they all live on the top-level of the structure, is this correct??
for name, member_config in pairs(operation.input.members) do
for name, member_config in pairs((operation.input or {}).members or {}) do
local param_value = params[name]
-- TODO: date-time value should be properly formatted???
if param_value ~= nil then
Expand Down

0 comments on commit a47ea82

Please sign in to comment.