Assign datetime.replace() return value in validate_file#3141
Open
bysiber wants to merge 1 commit into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3141 +/- ##
=============================================
+ Coverage 87.793% 87.817% +0.024%
=============================================
Files 105 105
Lines 8143 8143
Branches 1290 1290
=============================================
+ Hits 7149 7151 +2
+ Misses 687 686 -1
+ Partials 307 306 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
validate_file()callsdatetime.replace(tzinfo=timezone.utc)to normalize tz-naive datetimes before comparinglast_modifiedandif_modified_sincetimestamps. However,datetime.replace()returns a new datetime — it doesn't mutate in place. Since the return values aren't assigned back, both variables remain tz-naive after the "fix."The practical effect: on any server not running in UTC,
last_modified.timestamp()interprets the tz-naive datetime as local time while the tz-aware one is interpreted as UTC. This produces incorrect comparisons and breaks HTTP 304 Not Modified responses — either serving stale content or forcing unnecessary re-downloads depending on the timezone offset direction.