Skip to content

Commit c193c16

Browse files
committed
Leave next-url patch enabled, but add warning if still used
Testing shows that the patch for the ‘next-url’ is no longer needed; however to prevent possible issues and to raise visibility if the patch is still needed, leave it enabled but raise a warning if the `max=null` is still being found in returned `next-url`s.
1 parent 299e351 commit c193c16

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

ciscosparkapi/restsession.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,22 @@ def _fix_next_url(next_url):
6666
"""
6767
next_url = str(next_url)
6868
parsed_url = urllib.parse.urlparse(next_url)
69+
6970
if not parsed_url.scheme or not parsed_url.netloc or not parsed_url.path:
7071
error_message = "'next_url' must be a valid API endpoint URL, " \
7172
"minimally containing a scheme, netloc and path."
7273
raise ciscosparkapiException(error_message)
74+
7375
if parsed_url.query:
7476
query_list = parsed_url.query.split('&')
7577
if 'max=null' in query_list:
7678
query_list.remove('max=null')
79+
warnings.warn("`max=null` still present in next-URL returned "
80+
"from Cisco Spark", ResourceWarning)
7781
new_query = '&'.join(query_list)
7882
parsed_url = list(parsed_url)
7983
parsed_url[4] = new_query
84+
8085
return urllib.parse.urlunparse(parsed_url)
8186

8287

@@ -340,9 +345,11 @@ def get_pages(self, url, params=None, **kwargs):
340345
if response.links.get('next'):
341346
next_url = response.links.get('next').get('url')
342347

343-
# TODO: Test to see if fix is still needed.
344348
# Patch for Cisco Spark 'max=null' in next URL bug.
345-
# url = _fix_next_url(next_url)
349+
# Testing shows that patch is no longer needed; raising a
350+
# warnning if it is still taking effect;
351+
# considering for future removal
352+
url = _fix_next_url(next_url)
346353

347354
# Subsequent requests
348355
response = self.request('GET', next_url, erc, **kwargs)

0 commit comments

Comments
 (0)