fix(report): correctly parse millisecond Unix timestamps in report expiration checks#652
Conversation
30405a5 to
14f8fe8
Compare
14f8fe8 to
ee813ba
Compare
…piration checks Coverage report processors (Jacoco, Cobertura, Clover) were incorrectly flagging valid reports as expired when timestamps were in milliseconds (13+ digits) instead of seconds (10 digits). The timestring.Date() library expects seconds-based Unix timestamps, but some tools (like certain Clover implementations) emit millisecond timestamps. This caused ~1.5M false 'ReportExpiredException' errors in Sentry. Changes: - Add normalize_timestamp() helper to convert millisecond timestamps to seconds - Apply normalization in jacoco.py, cobertura.py, and clover.py - Add comprehensive unit tests for the helper and timestamp handling Fixes WORKER-Q95, WORKER-Q96, WORKER-Q97
ee813ba to
33ec955
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #652 +/- ##
=======================================
Coverage 93.35% 93.35%
=======================================
Files 1292 1292
Lines 47126 47138 +12
Branches 1567 1567
=======================================
+ Hits 43994 44006 +12
Misses 2823 2823
Partials 309 309
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Addresses Bugbot feedback: normalize_timestamp() can return None for empty strings, and Date(None) raises TypeError instead of TimestringInvalid. Now we check if timestamp is truthy before attempting to parse it, consistent with clover.py and jacoco.py.
Addresses review feedback - the docstring in normalize_timestamp() already explains the millisecond handling, so inline comments were repetitive.
|
Addressed the review feedback: Re: Missing truthy check (cursor[bot]) Re: Redundant comments |
Summary
Coverage report processors (Jacoco, Cobertura, Clover) were incorrectly flagging valid reports as expired when timestamps were in milliseconds (13+ digits) instead of seconds (10 digits).
The Problem
The
timestring.Date()library expects seconds-based Unix timestamps, but some tools emit millisecond timestamps (13 digits like1768258631332). When passed directly toDate(), these are parsed incorrectly, causing valid reports to be flagged as expired.Example from Sentry:
1768258631332(milliseconds)Date()interprets it as: Year 58003 (overflow/incorrect)ReportExpiredExceptioneven though the report is validImpact
This was causing ~1.5M false errors/month in Sentry:
Solution
Added
normalize_timestamp()helper that detects millisecond timestamps (13+ digits) and converts them to seconds before passing totimestring.Date().Changes
base.py: Addednormalize_timestamp()helper functionjacoco.py: Apply normalization before Date comparisoncobertura.py: Apply normalization before Date comparisonclover.py: Apply normalization before Date comparisonTesting
normalize_timestamp()helperFixes WORKER-Q95, WORKER-Q96, WORKER-Q97
Note
Ensures coverage report expiration checks work with millisecond Unix timestamps by normalizing to seconds before
timestring.Date()parsing.normalize_timestamp()inlanguages/base.pyto convert 13+ digit Unix timestamps to secondsclover.py,cobertura.py, andjacoco.py; exception messages now include the original timestampnormalize_timestamp()and updated expiration tests for all three processors, including recent millisecond "not expired" casesWritten by Cursor Bugbot for commit e5eb9c4. This will update automatically on new commits. Configure here.