Skip to content

Conversation

@ansgar-forestier
Copy link
Contributor

I have faced unclear error output('Invalid server response') when tried to send big audio ~ 200mb via bot.send_audio. It was hard to understand that now you can upload files up to 50 MB using telegram api. So my small fix makes error output more clear by doing two things:

  • moving data pasing block after error checking
  • adding 413(Request Entity Too Large) status to check

@ansgar-forestier ansgar-forestier changed the title Try to process response data after checking errors, not before. Add 4… Make error output more clear for too big uploads. Jun 15, 2017
@jh0ker
Copy link
Member

jh0ker commented Jun 15, 2017

Please see the travis log

@ansgar-forestier
Copy link
Contributor Author

ansgar-forestier commented Jun 16, 2017

Ok, I see, there is a lot of connections with this error handling part. Client code and unit tests expect a certain behavior. So I will think how I can eject 413 error message gentle way.

@jh0ker
Copy link
Member

jh0ker commented Jun 16, 2017

@alateas That's not the point. The point is that you moved the part where message is parsed further down, and now other parts of the code that need that variable don't work

@jh0ker
Copy link
Member

jh0ker commented Jun 16, 2017

Oh I'm sorry, you already fixed that 😄

@ansgar-forestier
Copy link
Contributor Author

ansgar-forestier commented Jun 16, 2017

Reason of moving block of http error handling( https://github.com/python-telegram-bot/python-telegram-bot/blob/master/telegram/utils/request.py#L191-L200 ) up is this block will never be executed. Because if we, for example, get a 502 http error, any way data will parsed in 187 line and json parsing will raise ValueError in 134 line, because it will not be real json.

Any way my last fix was wrong too :)

@Eldinnie
Copy link
Member

Can't you insert the check between the 200-209 check and the message parsing in the original file? It doesn't need the message.

@ansgar-forestier
Copy link
Contributor Author

ansgar-forestier commented Jun 16, 2017

I can, but this check the similar with other http error checks at lines 191-200, will be strange to separate 413 http error check.

@tsnoam
Copy link
Member

tsnoam commented Jun 20, 2017

@alateas I have a fix for your fix :-)
however, it seems that you haven't allowed edits to your branch by maintainers. Can you please allow it and I'll push? See:
https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork/

@ansgar-forestier
Copy link
Contributor Author

@tsnoam Good news! Actually I have allowed maintainers edits, I rechecked it right now.

@tsnoam
Copy link
Member

tsnoam commented Jun 21, 2017

I failed to push my commit. I wonder if I do something wrong.
Anyhow, I just edited the code using the github web interface. I hope I haven't made any typo.
Now we'll wait for travis to see if it works.

@Eldinnie
Copy link
Member

I I see this correctly. The way it is in the latest commit it will never raise an error if there is an error but not in one of the error codes. Shouldn't we add an

else:
  raise NetworkError(message)

at the bottom?

@Eldinnie
Copy link
Member

Nevermind, it just fell off the screen. It looks good to me.

@Eldinnie Eldinnie self-requested a review June 22, 2017 07:14
@tsnoam tsnoam merged commit 45d4ea0 into python-telegram-bot:master Jun 22, 2017
@tsnoam
Copy link
Member

tsnoam commented Jun 22, 2017

@alateas thanks for your contribution.

@github-actions github-actions bot locked and limited conversation to collaborators Aug 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants