Skip to content

Commit 4c370ca

Browse files
author
jozanini
committed
fix for rate limit response bug
1 parent efe90bb commit 4c370ca

File tree

5 files changed

+229
-372
lines changed

5 files changed

+229
-372
lines changed

PAGINATION_FIX_README.md

Lines changed: 0 additions & 116 deletions
This file was deleted.

docs/contributing.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ Contributing Code
4747
.. code-block:: bash
4848
4949
python3 -m venv venv
50+
51+
# On Mac/Linux
5052
source venv/bin/activate
53+
# On Windows
54+
venv\Scripts\activate.bat
5155
5256
4. Install poetry.
5357

@@ -75,7 +79,7 @@ Contributing Code
7579
8. If you running the test suite locally, ensure your code passes all of the default tests. Use the ``test`` target and ensure all tests execute successfully.
7680

7781
.. code-block:: bash
78-
82+
# see below for more information on running the test suite locally
7983
make tests
8084
8185
9. Commit your changes.

src/webexpythonsdk/exceptions.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,28 @@ def __init__(self, response):
138138
assert isinstance(response, requests.Response)
139139

140140
# Extended exception attributes
141-
self.retry_after = max(1, int(response.headers.get("Retry-After", 15)))
141+
try:
142+
retry_after = int(response.headers.get("Retry-After", 15))
143+
except (ValueError, TypeError):
144+
# Handle malformed Retry-After headers gracefully
145+
# Log a warning for debugging purposes
146+
import logging
147+
logger = logging.getLogger(__name__)
148+
logger.warning(
149+
f"Malformed Retry-After header received: {response.headers.get('Retry-After')}. "
150+
"Defaulting to 15 seconds."
151+
)
152+
retry_after = 15
153+
154+
self.retry_after = max(1, retry_after)
142155
"""The `Retry-After` time period (in seconds) provided by Webex.
143156
144157
Defaults to 15 seconds if the response `Retry-After` header isn't
145158
present in the response headers, and defaults to a minimum wait time of
146159
1 second if Webex returns a `Retry-After` header of 0 seconds.
160+
161+
Note: If the Retry-After header contains malformed values (non-integer strings,
162+
etc.), it will default to 15 seconds and log a warning.
147163
"""
148164

149165
super(RateLimitError, self).__init__(response)

0 commit comments

Comments
 (0)