Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix s3 v3 preconditions #9448

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

Merged
merged 1 commit into from
Oct 24, 2023
Merged

fix s3 v3 preconditions #9448

merged 1 commit into from
Oct 24, 2023

Conversation

bentsku
Copy link
Contributor

@bentsku bentsku commented Oct 23, 2023

Motivation

Using the object_store rust crate test suite, I've spotted an issue in our handling of preconditions for v3.
Basically, the LastModified field on the S3 object is stored with millisecond precision for internal use like sorting when calling ListObjects*.

But when comparing against ModifiedSince/UnmodifiedSince preconditions headers, those are sent using second precision, and we need to check for strict equality/superiority/inferiority. So something like the following should not be true if the precision is second:
last_modified=datetime.datetime(2023, 10, 23, 16, 19, 41, 798495, tzinfo=zoneinfo.ZoneInfo(key='GMT')) > if_unmodified_since=datetime.datetime(2023, 10, 23, 16, 19, 41, tzinfo=datetime.timezone.utc)

Changes

Adapted the check by rounding last modified before comparison, and created 2 AWS tests.

@bentsku bentsku added aws:s3 Amazon Simple Storage Service semver: patch Non-breaking changes which can be included in patch releases labels Oct 23, 2023
@bentsku bentsku self-assigned this Oct 23, 2023
@bentsku bentsku requested a review from macnev2013 as a code owner October 23, 2023 16:29
@coveralls
Copy link

Coverage Status

coverage: 82.93% (+0.005%) from 82.925% when pulling 39469fd on fix-s3-v3-preconditions into 829fcf1 on master.

@github-actions
Copy link

LocalStack Community integration with Pro

       2 files  ±0         2 suites  ±0   1h 16m 51s ⏱️ + 2m 10s
2 263 tests ±0  1 688 ✔️ ±0  575 💤 ±0  0 ±0 
2 264 runs  ±0  1 688 ✔️ ±0  576 💤 ±0  0 ±0 

Results for commit 39469fd. ± Comparison against base commit 829fcf1.

Copy link
Contributor

@macnev2013 macnev2013 left a comment

Choose a reason for hiding this comment

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

LGTM 👍🏻

@bentsku bentsku merged commit aab60be into master Oct 24, 2023
@bentsku bentsku deleted the fix-s3-v3-preconditions branch October 24, 2023 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws:s3 Amazon Simple Storage Service semver: patch Non-breaking changes which can be included in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants