Skip to content

Commit 9c7c84c

Browse files
authored
fix(request): anticipate operations with no inputs (#108)
1 parent f6a4468 commit 9c7c84c

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ Release process:
188188
- feat: container credential provider now supports using auth token defined in
189189
AWS_CONTAINER_AUTHORIZATION_TOKEN and AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE.
190190
[107](https://github.com/Kong/lua-resty-aws/pull/107)
191+
- fix: operations without inputs (eg, some S3 ones) would cause errors to be thrown
192+
[108](https://github.com/Kong/lua-resty-aws/pull/108)
191193

192194
### 1.3.6 (25-Dec-2023)
193195

src/resty/aws/init.lua

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,16 @@ local function generate_service_methods(service)
303303
method_name)
304304

305305
service[method_name] = function(self, params)
306+
params = params or {}
306307

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

309-
-- validate parameters
310-
local ok, err = validate_input(params, operation.input, "params")
311-
if not ok then
312-
return nil, operation_prefix .. " validation error: " .. tostring(err)
310+
-- validate parameters if we have any; eg. S3 "listBuckets" has none
311+
if operation.input then
312+
local ok, err = validate_input(params, operation.input, "params")
313+
if not ok then
314+
return nil, operation_prefix .. " validation error: " .. tostring(err)
315+
end
313316
end
314317

315318
-- implement stsRegionalEndpoints config setting,

src/resty/aws/request/build.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ local function build_request(operation, config, params)
157157

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

0 commit comments

Comments
 (0)