philippnormann / nvidia-sniper

🎯 Autonomously buy Nvidia Founders Edition GPUs as soon as they become available.
396 stars 99 forks source link

API Inventory Failure 28th Sept #27

Closed LonleyViper closed 4 years ago

LonleyViper commented 4 years ago

Looks like the api has changed again? Is this something we can fix?

2020-09-28 23:04:02,066 nvidia-sniper: Failed to get inventory status for 5438792700
Traceback (most recent call last):

  File "/Users/<username>/Documents/nvidia-sniper/sniper/__main__.py", line 47, in checkout_api
    inventory = await api.get_inventory_status(session, dr_locale, api_currency, dr_id)

  File "/Users/<username>/Documents/nvidia-sniper/sniper/api.py", line 22, in get_inventory_status
    json_resp = await response.json()

  File "/Users/<username>/.local/share/virtualenvs/nvidia-sniper-V5mCHnvd/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 1026, in json

    raise ContentTypeError(

aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html', url=URL('https://api-prod.nvidia.com/direct-sales-shop/DR/products/en_gb/GBP/5438792700')
HiramIII commented 4 years ago

Yeah same

krcm0209 commented 4 years ago

This is expected behavior when the API is down

ericchansen commented 4 years ago

What if we gave a useful error message when this happens? For example, we could provide the full traceback and add something like, "This is the expected behavior when the NVIDIA API is down."

LonleyViper commented 4 years ago

Might be hard to tell if it's that the api is down or substancially changed? Not a code though lol

krcm0209 commented 4 years ago

Perhaps the messaging could change based on if the error is a JSON decode error or an error interpreting valid JSON. One might expect that they likely will not update the API and remove the use of JSON entirely. If they change things, the payload will likely still be JSON, but just have different keys and values. So by detecting invalid JSON, we could be confident that the API is down, and not just changed.

philippnormann commented 4 years ago

As @krcm0209 this behavior is currently expected as the site and API have been down since yesterday.