Skip to content

Commit 99762dd

Browse files
committed
fix(request): anticipate operations with no inputs
1 parent f6a4468 commit 99762dd

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/resty/aws/init.lua

+7-4
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

+1-1
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)