cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
295
Views
0
Helpful
2
Replies

Cisco API bug - EOXBySWReleaseString

maciejlaskowski
Level 1
Level 1

Hello guys,

I’m struggling with an error that happen when we request the EOXBySWReleaseString endpoint for several times; the goal being to fetch the EOX date for multiple versions of IOS. 

I run the test in Pycharm, the first results work fine, but after 20 to 30 minutes I get the Error below: 

—————————————————————————————————————————————————————————————————————————————

 

Traceback (most recent call last):
  File "/Users/ohaoudi/Library/Caches/pypoetry/virtualenvs/vc-plugin-cisco-9TpR3yms-py3.11/lib/python3.11/site-packages/tenacity/_asyncio.py", line 61, in __call__
    result = await fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ohaoudi/rapid7/vc-plugin-cisco/percy/cisco/api/cisco_api_connector.py", line 81, in _make_request
    response.raise_for_status()
  File "/Users/ohaoudi/Library/Caches/pypoetry/virtualenvs/vc-plugin-cisco-9TpR3yms-py3.11/lib/python3.11/site-packages/httpx/_models.py", line 761, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '403 Forbidden' for url 'https://apix.cisco.com/supporttools/eox/rest/5/EOXBySWReleaseString/1/?input1=12.2%2812h%29%2CIOS'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/Users/ohaoudi/rapid7/vc-plugin-cisco/percy/cisco/etl/extract/extract.py", line 139, in extract_eoss_sw_products
    all_versions_list = await cisco_service.get_IOS_versions(repository)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ohaoudi/rapid7/vc-plugin-cisco/percy/cisco/service/cisco_service.py", line 356, in get_IOS_versions
    async for item in self.connector.get_first_page_eox_by_version("IOS", version):
  File "/Users/ohaoudi/rapid7/vc-plugin-cisco/percy/cisco/api/cisco_api_connector.py", line 283, in get_first_page_eox_by_version
    response = await self._make_request(session, url)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ohaoudi/Library/Caches/pypoetry/virtualenvs/vc-plugin-cisco-9TpR3yms-py3.11/lib/python3.11/site-packages/tenacity/_asyncio.py", line 142, in async_wrapped
    return await fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ohaoudi/Library/Caches/pypoetry/virtualenvs/vc-plugin-cisco-9TpR3yms-py3.11/lib/python3.11/site-packages/tenacity/_asyncio.py", line 58, in __call__
    do = await self.iter(retry_state=retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ohaoudi/Library/Caches/pypoetry/virtualenvs/vc-plugin-cisco-9TpR3yms-py3.11/lib/python3.11/site-packages/tenacity/_asyncio.py", line 110, in iter
    result = await action(retry_state)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ohaoudi/Library/Caches/pypoetry/virtualenvs/vc-plugin-cisco-9TpR3yms-py3.11/lib/python3.11/site-packages/tenacity/_asyncio.py", line 78, in inner
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/ohaoudi/Library/Caches/pypoetry/virtualenvs/vc-plugin-cisco-9TpR3yms-py3.11/lib/python3.11/site-packages/tenacity/__init__.py", line 411, in exc_check
    raise retry_exc from fut.exception()
tenacity.RetryError: RetryError[<Future at 0x12b65a690 state=finished raised HTTPStatusError>]
python-BaseException

 

—————————————————————————————————————————————————————————————————————————————

Notes : 

1- when I run the requested url that cause the bug in postman client it works fine and I get the EOXRecord. 

2- running the test immediately after produce the same bug but with a different url each time [ which again works fine when requested separately ]

do you have an idea on what might cause this error ? is it an api error or Python related error ? [ may be some caching mechanism ? ]

many thanks for your help.

2 Replies 2

Not an expert here, just thoughts. The HTTP client implementation in your Python code might be different from Postman which could lead to differences in how the request is constructed, headers are set, or how the response is handled. I saw the code error is using asyncio and tenacity, so it is possible that concurrency issues are causing the problem here, this could be overwhelming the API with too many concurrent requests, you can try reducing the concurrency level or using a semaphore to limit the number of concurrent requests.

Hope this helps.

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

maciejlaskowski
Level 1
Level 1

Thank's a lot! We'll check it out.