New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Avoid raising 404 when file cannot generate a thumbnail #642
Conversation
Co-authored-by: Marcin Hagmajer <mhagmajer@users.noreply.github.com>
This limit is set, because >=3.5.0 versions require Rust
…older (box#637) Closes: SDK-1815
d4eba16
to
3eaa3ed
Compare
Pull Request Test Coverage Report for Build 2739
💛 - Coveralls |
Hi @DaveSawyer , Thanks for this contribution! We will review it ASAP! |
boxsdk/object/file.py
Outdated
if representation: | ||
url = representation[0]['content']['url_template'] | ||
representations = self.get_representation_info(rep_hints) | ||
if len(representations): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An empty list is treated as False, so if representations:
is enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK. I have some questions.
Please wait with merging until we solve the travis build issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing that I overlooked - could you ad an entry to HISTORY.srt
Also pylint is failing with messages: test.unit.object.test_file:950:11: [C0122(misplaced-comparison-constant), test_get_thumbnail_representation_not_available] Comparison should be thumb == ''` |
test/unit/object/test_file.py
Outdated
@@ -901,4 +901,50 @@ def test_get_thumbnail_representation_not_found( | |||
headers={'X-Rep-Hints': '[{}?dimensions={}]'.format(extension, dimensions)}, | |||
params={'fields': 'representations'}, | |||
) | |||
assert thumb == b'' | |||
assert b'' == thumb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert thumb == b''
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are equivalent and in general it's better to put a constant on the left so you don't accidentally have an assignment from a typo. This is the existing code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point, but according to pylint the other way around it preferred, see: https://vald-phoenix.github.io/pylint-errors/plerr/errors/basic/C0122 . Without fixing it the build will be still failing.
test/unit/object/test_file.py
Outdated
headers={'X-Rep-Hints': '[{}?dimensions={}]'.format(extension, dimensions)}, | ||
params={'fields': 'representations'}, | ||
) | ||
assert b'' == thumb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert thumb == b''
Hi, @DaveSawyer thanks for contributing! I took over your pr because for today a new release is planned and we wanted to include your change in it. |
for issue #641. For some files that cannot generate thumbnails we should not attempt to download from the url field. If we do, an application may interpret the 404 not found as similar to "try again in case the thumbnail was in the process of being generated." We can also avoid an extra network call that we know will fail.
I made this intentionally narrow (as opposed to status != 'success') because some failures might be solved by waiting and retrying or actually have a valid URL.