You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by dg...@apache.org on 2019/05/29 13:54:57 UTC

[incubator-openwhisk-apigateway] branch master updated: Guard against missing query parameters. (#343)

This is an automated email from the ASF dual-hosted git repository.

dgrove pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-apigateway.git


The following commit(s) were added to refs/heads/master by this push:
     new 4071f82  Guard against missing query parameters. (#343)
4071f82 is described below

commit 4071f82cf0a6adaafae206a1d197f0a636e8671c
Author: rodric rabbah <ro...@gmail.com>
AuthorDate: Wed May 29 09:54:52 2019 -0400

    Guard against missing query parameters. (#343)
---
 scripts/lua/management/lib/tenants.lua | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/scripts/lua/management/lib/tenants.lua b/scripts/lua/management/lib/tenants.lua
index 314da92..a83c773 100644
--- a/scripts/lua/management/lib/tenants.lua
+++ b/scripts/lua/management/lib/tenants.lua
@@ -114,7 +114,7 @@ function _M.getTenantAPIs(dataStore, id, queryParams)
       end
     end
   end
-  if ((queryParams['skip']  == nil and queryParams['limit'] == nil) or table.getn(apiList) == 0) then
+  if (((queryParams['skip'] == nil or queryParams['skip'] == 'undefined') and (queryParams['limit'] == nil or queryParams['limit'] == 'undefined')) or table.getn(apiList) == 0) then
     return apiList
   else
     return applyPagingToAPIs(apiList, queryParams)
@@ -127,10 +127,14 @@ end
 function applyPagingToAPIs(apiList, queryParams)
   local skip  = queryParams['skip']  == nil and 1 or queryParams['skip']
   local limit = queryParams['limit'] == nil and table.getn(apiList) or queryParams['limit']
-  if (tonumber(limit) < 1) then
+
+  skip = tonumber(skip)
+  limit = tonumber(limit)
+
+  if (limit == nil or limit < 1) then
     return {}
   end
-  if (tonumber(skip) <= 0) then
+  if (skip == nil or skip <= 0) then
     skip = 1
   else
     skip = skip + 1