You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: keep milliseconds in datetime start and end bounds - #752
A datetime passed as start or end to channel history() or stats() is truncated to whole seconds. For example, 12:00:00.999 is sent as ...12:00:00.000, so a window ending there leaves out up to 999 ms of results.
The cause is that format_time_param computes calendar.timegm(t.utctimetuple()) * 1000, and a time tuple has no sub-second field. The fix adds t.microsecond // 1000. This matches what presence history() already sends (_ms_since_epoch in ably/pubsub/types/presence.py). Naive datetimes are still read as UTC, and non-datetime values are passed through as before.
A parametrized test in test/unit/paginatedresult_test.py covers UTC, offset-aware and naive datetimes. It fails without the change and passes with it. The paginated result, stats and channel unit tests pass, and ruff is clean.
This change was prepared with the help of an AI coding assistant.
Summary by CodeRabbit
Bug Fixes
Paginated result queries now preserve timestamp precision to the millisecond, preventing records near a requested start or end time from being missed due to discarded fractional seconds.
Datetime bounds now produce consistent millisecond query parameters for UTC, offset-aware, and naive values.
Review was skipped as selected files did not have any reviewable changes.
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 284aacfe-5a15-4907-aceb-854707f3aa50
Commits
Reviewing files that changed from the base of the PR and between d6ccb5d and 5594f94.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
Datetime query bounds now retain millisecond precision. Tests cover UTC-aware, offset-aware, and naive datetime values for both start and end.
Changes
Datetime bound precision
Layer / File(s)
Summary
Format datetime bounds ably/pubsub/request/paginatedresult.py, test/unit/paginatedresult_test.py
format_time_param adds the datetime’s microseconds, truncated to milliseconds. Parameterized tests verify that all three datetime forms produce 1704110400999 for both bounds.
Datetime start and end bounds now keep millisecond precision in channel history and stats queries. The change is small, covered by tests, and easy to revert, so merge risk is minimal.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: datetime start and end bounds now keep milliseconds. The raw summary says format_time_param now includes microseconds truncated to milliseconds, and the objectives des…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: datetime start and end bounds now keep milliseconds. The raw summary says format_time_param now includes microseconds truncated to milliseconds, and the objectives describe adding t.microsecond // 1000 to the timestamp calculation. The title is specific, concise, and matches the changeset.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Fix failing CI checks
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit checks the clock’s fine hand, Milliseconds now join the band. UTC, offset, and plain time agree, Start and end keep precision neatly. The bounds hop on, no second lost.
Recent review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 14a5f22d-ada2-4f1a-b38b-fdeacdce412f
Commits
Reviewing files that changed from the base of the PR and between 2435510 and d6ccb5d.
Files selected for processing: 2
ably/pubsub/request/paginatedresult.py
test/unit/paginatedresult_test.py
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
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
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.
A
datetimepassed asstartorendto channelhistory()orstats()is truncated to whole seconds. For example,12:00:00.999is sent as...12:00:00.000, so a window ending there leaves out up to 999 ms of results.The cause is that
format_time_paramcomputescalendar.timegm(t.utctimetuple()) * 1000, and a time tuple has no sub-second field. The fix addst.microsecond // 1000. This matches what presencehistory()already sends (_ms_since_epochinably/pubsub/types/presence.py). Naive datetimes are still read as UTC, and non-datetime values are passed through as before.A parametrized test in
test/unit/paginatedresult_test.pycovers UTC, offset-aware and naive datetimes. It fails without the change and passes with it. The paginated result, stats and channel unit tests pass, and ruff is clean.This change was prepared with the help of an AI coding assistant.
Summary by CodeRabbit