Skip to content

ValueError When Handling Retry-After Headers After 429 Too Many Requests Error #1159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gilron07 opened this issue Mar 25, 2025 · 4 comments
Labels
type:bug A broken experience

Comments

@gilron07
Copy link

Describe the bug

The issue arises after encountering a 429 Too Many Requests error, which likely returns an incorrect Retry-After header value like 30,120 (representing two retry times or a malformed retry interval). When the retry handler attempts to process this value, it throws an error because it cannot properly parse the value into an integer due to the comma.

<kiota_http.middleware.retry_handler.RetryHandler object at 0x1104f2780>
retry_after = '30,120'

    def _parse_retry_after(self, retry_after):
        """
        Helper to parse Retry-After and get value in seconds.
        """
        try:
>           delay = int(retry_after)
E           ValueError: invalid literal for int() with base 10: '30,120'

Expected behavior

  • Server returns proper Retry After value
  • Client is able to properly parse value & retry request or if still gets 429, throw an appropriate HTTP exception.

How to reproduce

Steps to Reproduce:

  • Trigger a 429 Too Many Requests error by sending multiple simultaneous requests to sites graph endpoint:
    client.sites.get(request_configuration=request)

  • Observe that the Retry-After header contains the value "30,120".

  • The retry handler fails with the error ValueError: invalid literal for int() with base 10: '30,120'.

SDK Version

1.26.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

Click to expand log ``` self = retry_after = '30,120'
def _parse_retry_after(self, retry_after):
    """
    Helper to parse Retry-After and get value in seconds.
    """
    try:
      delay = int(retry_after)

E ValueError: invalid literal for int() with base 10: '30,120'

../.venv/lib/python3.xx/site-packages/kiota_http/middleware/retry_handler.py:205: ValueError

</details>


### Configuration

_No response_

### Other information

_No response_
@gilron07 gilron07 added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Mar 25, 2025
@MarcoP9
Copy link

MarcoP9 commented Mar 27, 2025

Experiencing the exact same problem!

@MarcoP9
Copy link

MarcoP9 commented Apr 10, 2025

Hello! Is there any update on this? What could be a possible workaround?

@metealp
Copy link

metealp commented Apr 14, 2025

same here

@musale
Copy link

musale commented Apr 15, 2025

@gilron07 good catch. This seems to be a casting issue in the http retry middleware.
https://github.com/microsoft/kiota-python/blob/cc340dcc928bbee96a7abb7c18752b892684fc83/packages/http/httpx/kiota_http/middleware/retry_handler.py#L200-L210

Updating this to cater for the returned comma-separated ints and pick the correct one should do the trick. Are you interested in picking this up?

@musale musale removed the status:waiting-for-triage An issue that is yet to be reviewed or assigned label Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug A broken experience
Projects
None yet
Development

No branches or pull requests

4 participants