[#387] Do not escape the "timeout" parameter. (#394)

* [#387] Do not escape the "timeout" parameter.

When the "timeout" parameter is escaped and turned into
a string, it does not pass validation checks.
This PR ensures that timeout is passed through as-is,
just like "request_timeout".
There's no explicit test for this parameter, but I included
it on some existing tests just to ensure that the code
is exercised.  Without the fix in place, one of the tests as modified will not pass.

Signed-off-by: Charles Greer <[email protected]>

* Unit test for timeout parameter

Revert original test modifications.

Signed-off-by: Charles Greer <[email protected]>

* Extend test and linter

Signed-off-by: Charles Greer <[email protected]>

---------

Signed-off-by: Charles Greer <[email protected]>
This commit is contained in:
Charles Greer
2023-05-23 18:12:29 -04:00
committed by GitHub
parent 0395798d2b
commit fe3b5a8922
3 changed files with 33 additions and 5 deletions
+5 -4
View File
@@ -165,16 +165,17 @@ def query_params(*opensearch_query_params):
elif api_key is not None:
headers["authorization"] = "ApiKey %s" % (_base64_auth_header(api_key),)
# don't escape ignore, request_timeout, or timeout
for p in ("ignore", "request_timeout", "timeout"):
if p in kwargs:
params[p] = kwargs.pop(p)
for p in opensearch_query_params + GLOBAL_PARAMS:
if p in kwargs:
v = kwargs.pop(p)
if v is not None:
params[p] = _escape(v)
# don't treat ignore, request_timeout, and opaque_id as other params to avoid escaping
for p in ("ignore", "request_timeout"):
if p in kwargs:
params[p] = kwargs.pop(p)
return func(*args, params=params, headers=headers, **kwargs)
return _wrapped