urschrei / pyzotero

Pyzotero: a Python client for the Zotero API
https://pyzotero.readthedocs.org
Other
908 stars 99 forks source link

Bad Gateway errors #165

Open denismaier opened 1 year ago

denismaier commented 1 year ago

I've started getting "Bad gateway" errors in a script that previously was working flawlessly.

pyzotero.zotero_errors.HTTPError:
Code: 504
URL: https://api.zotero.org/groups/1234567890/items/top?itemType=book&limit=100&start=300
Method: GET
Response: <html>
<head><title>504 Gateway Time-out</title></head>
<body>
<center><h1>504 Gateway Time-out</h1></center>
</body>
</html>

How does pyzotero handle these kinds of errors? Do I need to handle the error catching in my script, or is there a way to let pyzotero retry whatever it was trying to do?

urschrei commented 1 year ago

You'll need to catch the HTTPError exception and handle the retry logic yourself – Pyzotero only retries 429 errors as there isn't really a one-size-fits-all approach to HTTP errors beyond that, IMO.

denismaier commented 1 year ago

Ok. thanks. I'll have a look. (Only thing that gives me headaches is that I'm using the everything retrieving method, and the error occurs after a couple of successfull retrievals, and I don't know how to resume where things went wrong instead of making a completely new start.)

urschrei commented 1 year ago

Since the error returns the URL, you could extract the start parameter (300) in your example above, and use that as input for whichever top query you were running – they should all accept e.g. a start=300 param.

denismaier commented 1 year ago

Sounds good---but are the successful requests preserved somewhere so I can just add to them?

urschrei commented 1 year ago

I'll have to think about it, but I think that's going to be very difficult…