Skip to content

Conversation

@fabiosantoscode
Copy link
Contributor

@fabiosantoscode fabiosantoscode commented Jan 16, 2020

The reason for this problem is a 301 without a Location header. In our HTTP remote we can treat this as an error, since we don't know where to actually find the data.

Fixes #2963


  • ❗ 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 addressed. 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. 🙏

@fabiosantoscode fabiosantoscode changed the title pull: treat HTTP redirects without Location header as error (WIP) pull: treat HTTP redirects without Location header as error Jan 16, 2020
@fabiosantoscode fabiosantoscode requested a review from efiop January 16, 2020 14:52
@fabiosantoscode fabiosantoscode changed the title (WIP) pull: treat HTTP redirects without Location header as error pull: treat HTTP redirects without Location header as error Jan 16, 2020
Comment on lines 106 to 110
if kwargs["allow_redirects"] and res.status_code in (301, 302):
# AWS s3 doesn't like to add a location header to its redirects
# from https://s3.amazonaws.com/<bucket name>/* type URLs.
# This should be treated as an error
raise requests.exceptions.RequestException
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if this is not s3 and location header is present?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then requests would've followed the redirect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better to be explicit and check that a location header is not present?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that would be better. At least the comment will follow the code, now it looks like a bug in implementation. So adjusting comment would be good too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense

@fabiosantoscode fabiosantoscode requested a review from Suor January 16, 2020 20:32
@efiop
Copy link
Contributor

efiop commented Jan 19, 2020

@fabiosantoscode For the record, your fix doesn't really address #2963 , because that issue is about push, which won't work anyways because we don't have support for uploading through HTTP remote. Plus in that issue another concern is that dvc push, when doesn't need to push anything, doesn't even try to access the remote as a sanity check.

Your PR is still useful, but I don't have any way of reproducing the issue that it is solving. But looks alright - so merging. Thanks! 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dvc pull with wrong S3 remote failed but user wasn't informed

3 participants