Open nukaboy opened 1 year ago
hm, this is odd!
As for what I know is going on from this stacktrace - Cohost.py assumes whatever being sent back over the API is encoded in JSON. So, this error occurs when Cohost is sending some non-JSON response over the API back to us. In the past this was seen when we got hit with Cohost's DDOS protection (at the time being Cloudflare) blocking Cohost.py - changing the user agent fixed that though.
My guess (without knowing what's in the failing request...) is that something similar is happening, but only triggering when uploading lots of data.
Interestingly though, this is looking like Cohost is sending... nothing back. We raise an exception, with what should be the contents of the response, and, nothing is in the console. Quick sample showcasing this is probably an empty string being passed, using the Python interpreter.
In this example, note
: demo!"
afterException
on the last line
Type "help", "copyright", "credits" or "license" for more information.
>>> raise Exception("demo!")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
Exception: demo!
In this example, not there is no string, and no semicolon
>>> raise Exception("")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
Exception
>>>
Also interestingly, this is failing when we're requesting credentials to upload, and isn't failing at the step we're uploading images. As such, I'm really curious why Cohost isn't sending any data back. My best guess is that it sends nothing back when the 'content_length'
is too high.
Just as I'm a little busy having some kind of cold / sickness (I'm mostly typing this looking away from the laptop screen, because the glare is Not It 😭 ), could you let me know:
network.py
?thanks for raising an issue, and thanks for using cohost.py!
Thanks for your response! As it turns out, the whole thing was entirely my fault: The bot randomly went through a folder of pictures to post, then removing them. There were, however, a few pictures with a size >10MB. As there were less other pictures to choose from, more and more are oversized until only those were left... So the bug is i guess the inability to handle the response for too large attachment files. Again, thanks for your help, for making the library & get well soon!
No worries! I'll leave this open, just rename to be an FR for clearer errors when using images bigger than 10mb.
I have a bot that posts fairly large images (up to around 4 MB). First it ran fine, but over time more and more regularely
project.post()
fails with following error message, up to the point that it now fails every time:The relevant code is
I have two other bots (one that posts small images and one that posts text only) that run without issues with basically the same code.