Repository navigation
Conversation
created_after and created_before accept an ISO 8601 datetime with any UTC offset, but the offset was passed through to the query. PyMySQL drops the offset when binding a datetime, while TestProgress timestamps are stored in UTC, so 2024-01-02T00:00:00+05:30 was compared as 2024-01-02 00:00 UTC instead of 2024-01-01 18:30 UTC. Convert the parsed value to UTC first.
kaihere14
requested review from
canihavesomecoffee and
thealphadollar
as code owners
November 26, 2026 16:27
|
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.



In raising this pull request, I confirm the following (please check boxes):
My familiarity with the project is as follows (check one):
The problem
The API lets you filter runs by date with
created_afterandcreated_before. These filters are used byGET /api/v1/runsandGET /api/v1/samples/{id}/history.If you give the date with a timezone, like
2024-01-02T00:00:00+05:30, the timezone is ignored. The platform stores run times in UTC, so this date should mean 18:30 UTC on Jan 1. Instead it is treated as 00:00 UTC on Jan 2, which is 5.5 hours off.Because of this, the filter can leave out runs it should return, or return runs it should leave out. It does this without showing any error.
Only dates with a timezone other than UTC are affected. Dates ending in
Zor+00:00, and dates with no timezone, work fine.How to reproduce
Take a run that started at
2024-01-01T20:00:00Z. The two dates below mean the same moment (18:30 UTC), so both should give the same answer. (%2Bis how+is written in a URL.)created_after=2024-01-01T18:30:00Zcreated_after=2024-01-02T00:00:00%2B05:30created_before=2024-01-01T18:30:00Zcreated_before=2024-01-02T00:00:00%2B05:30Why it happens
_parse_iso8601_date()inmod_api/middleware/validation.pyreads the date and keeps its timezone. When the date is sent to MySQL, the database driver (PyMySQL) drops the timezone part and keeps only the clock time. That clock time is then compared with times stored in UTC.The fix
_parse_iso8601_date()now converts the date to UTC before returning it. This is a one-line change inmod_api/middleware/validation.py. Both endpoints use this function, so both are fixed.Tests
tests/api/test_middleware_validation.py: checks that2024-01-02T00:00:00+05:30comes out as2024-01-01T18:30:00+00:00.tests/api/test_routes_runs.py: runs the example from the table above against/api/v1/runs.validation.py.