fastly / fastly-py

A Fastly API client for Python
https://pypi.org/project/fastly/
MIT License
77 stars 60 forks source link

X-RateLimit-Remaining sometimes contains multiple values #99

Open rkoopmans opened 8 months ago

rkoopmans commented 8 months ago

This was observed by our API that uses the generated fastly-py library;

Traceback (most recent call last):
  File "/app/manager/lib/cdn/fastly/__init__.py", line 79, in inner
    return f(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "/app/manager/lib/cdn/fastly/__init__.py", line 230, in create
    with self.transactional_version(service_id, 1) as version:
  File "/usr/local/lib/python3.11/contextlib.py", line 144, in __exit__
    next(self.gen)
  File "/app/manager/lib/cdn/fastly/__init__.py", line 639, in transactional_version
    VersionApi(self.client).activate_service_version(
  File "/app/.venv/lib/python3.11/site-packages/fastly/api/version_api.py", line 722, in activate_service_version
    return self.activate_service_version_endpoint.call_with_http_info(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/fastly/api_client.py", line 872, in call_with_http_info
    return self.api_client.call_api(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/fastly/api_client.py", line 427, in call_api
    return self.__call_api(resource_path, method,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/fastly/api_client.py", line 245, in __call_api
    self.rate_limit_remaining = int(response_data.getheader("Fastly-RateLimit-Remaining", default=DEFAULT_RATELIMIT))
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: '993, 999'

The double integer wasn't there before, so it may have been an error on Fastly's side, this however broke our code :-)