Skip to content
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

Slight readability improvement on etag preparation for files #771

Merged
merged 4 commits into from
Aug 18, 2023

Conversation

why-not-try-calmer
Copy link
Contributor

@why-not-try-calmer why-not-try-calmer commented Aug 17, 2023

As of current master the e_tag property of S3ObjectVersion will evaluate to None in certain edge cases, causing Exceptions (see for example https://github.com/opengisch/qfieldcloud-private/pull/474). This PR ensures S3ObjectVersion.e_tag never lies about its type.

@why-not-try-calmer why-not-try-calmer added bug Something isn't working bugfix and removed bug Something isn't working bugfix labels Aug 17, 2023
Copy link
Collaborator

@suricactus suricactus left a comment

Choose a reason for hiding this comment

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

Tried to find an explanation of a situation when the e_tag is None, but didn't find where it is. Would be interesting to share what is the situation when the e_tag is None and put it as a comment in the code.

IMO if such situation is real, we better return None than "", as we are lying whether the e_tag is present. So instead of adding the two ifs, it seems changing the return type makes more sense to me.

The above thoughts might be wrong when I see the reason when this happens.

docker-app/qfieldcloud/core/views/files_views.py Outdated Show resolved Hide resolved
@why-not-try-calmer
Copy link
Contributor Author

Tried to find an explanation of a situation when the e_tag is None, but didn't find where it is. Would be interesting to share what is the situation when the e_tag is None and put it as a comment in the code.

IMO if such situation is real, we better return None than "", as we are lying whether the e_tag is present. So instead of adding the two ifs, it seems changing the return type makes more sense to me.

The above thoughts might be wrong when I see the reason when this happens.

My bad, I narrowed the issue down to its actual culprit.

@suricactus
Copy link
Collaborator

@why-not-try-calmer I am still not sure when the version.etag is None? It only happens when we have a delete version, which should not be the case for any installation?

@why-not-try-calmer why-not-try-calmer removed the bug Something isn't working label Aug 18, 2023
@why-not-try-calmer
Copy link
Contributor Author

why-not-try-calmer commented Aug 18, 2023

Okay so thanks for showing how this in itself was not a bug. I've removed the bug label and this now boils down to a simple convenience PR.

Copy link
Collaborator

@suricactus suricactus left a comment

Choose a reason for hiding this comment

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

Thanks!

It turned out very strange behaviour that confirmed my suspision - you had a version about deletion of the file.

@suricactus suricactus changed the title S3objectversion etag Slight readability improvement on etag preparation for files Aug 18, 2023
@suricactus suricactus merged commit e6a036f into master Aug 18, 2023
12 checks passed
@suricactus suricactus deleted the s3objectversion_etag branch August 18, 2023 12:28
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.

2 participants