remote: http: raise exception when response with error status code#2794
Conversation
4ae7fe0 to
4f898fe
Compare
There was a problem hiding this comment.
Do we really need to invent a new exception class for each situation? This would be a nightmare if people will some time in the future use Repo class and try to handle errors. Also creates bloat.
This is question goes to everybody not only @pared.
There was a problem hiding this comment.
I agree that might be excessive in some situations, though, what alternative do we have?
Do you think I should use requests.HTTPError?
There was a problem hiding this comment.
We should probably discuss it separately. I didn't mean this a blocker for this particular PR, just used it as an example.
There was a problem hiding this comment.
And it can't be requests.HTTPError as we need to descend this from DvcException().
There was a problem hiding this comment.
Code and reason should go next to each other, separate by space. This how it is presented everywhere. We might also want to say that this is an HTTP error in the message.
There was a problem hiding this comment.
We don't split imports like that anymore)
There was a problem hiding this comment.
Is there any value in testing it 3 times?
There was a problem hiding this comment.
Simply use URLInfo(url) / "file.txt" or use URLInfo from the start. This will save you from an error of using os.path instead of posixpath.
There was a problem hiding this comment.
Do you really need to store this to an attribute?
5e06a19 to
aa5ca84
Compare
|
@pared Please rebase 😉 |
There was a problem hiding this comment.
This will show:
HTTPError: HTTP Error: 404 Not Found
There was a problem hiding this comment.
| total=None if no_progress_bar else self._content_length(from_info), | |
| total=None if no_progress_bar else self._content_length(response), |
I wonder why we are still doing this extra request, also ._content_length() doesn't need to work with url really.
There was a problem hiding this comment.
This is outside of your PR actually. But since you are here)
There was a problem hiding this comment.
But isn't the extra request done only if response does not contain Content-Length?
There was a problem hiding this comment.
If you pass url (path_info) and not response then you always make a second request. _content_length() should stop accepting urls and might be even inlined, this will prevent this inefficiency.
There was a problem hiding this comment.
That is right, sorry, I'll change accordingly. Though, I would leave _content_length as it is, in order to not obstruct _download method content.
There was a problem hiding this comment.
I don't think we need flush. It is probably a remnant from the time we did http resume.
There was a problem hiding this comment.
Do we actually need it? Can we simply ask for some missing url?
There was a problem hiding this comment.
Well, 404 is quite easy to generate
There was a problem hiding this comment.
The question now is, should we leave changes made to StaticFileServer.
@Suor what do you think? I think they should stay, as the previous version was mapping string to its handler class, which was unnecessary.
There was a problem hiding this comment.
Maybe use "missing.txt" to make it more obvious.
|
thanks, @pared ! looks good to me) |
|
@Suor Please take a look 🙂 |
There was a problem hiding this comment.
If you pass url (path_info) and not response then you always make a second request. _content_length() should stop accepting urls and might be even inlined, this will prevent this inefficiency.
There was a problem hiding this comment.
No need for this getattr() anymore, simply request.headers.
Co-Authored-By: Alexander Schepanovski <suor.web@gmail.com>
❗ Have you followed the guidelines in the Contributing to DVC list?
📖 Check this box if this PR does not require documentation updates, or if it does and you have created a separate PR in dvc.org with such updates (or at least opened an issue about it in that repo). Please link below to your PR (or issue) in the dvc.org repo.
❌ Have you checked DeepSource, CodeClimate, and other sanity checks below? We consider their findings recommendatory and don't expect everything to be addresses. Please review them carefully and fix those that actually improve code or fix bugs.
Thank you for the contribution - we'll try to review it as soon as possible. 🙏
Fixes #2510