preserve JSON entries with invalid numeric timestamps - #31
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideJSON log parsing is updated so that numeric timestamps that cannot be represented as datetimes no longer cause parsing failures; instead, the log entry is returned with a null timestamp, and tests are added to cover these cases. Sequence diagram for JSON numeric timestamp extraction with overflow handlingsequenceDiagram
participant JsonLogParser
participant _extract_timestamp
participant datetime
JsonLogParser->>_extract_timestamp: _extract_timestamp(data)
_extract_timestamp->>_extract_timestamp: [field has numeric value]
_extract_timestamp->>datetime: fromtimestamp(value or value/1000)
alt timestamp convertible
datetime-->>_extract_timestamp: datetime
_extract_timestamp-->>JsonLogParser: return parsed datetime
else timestamp not representable
datetime-->>_extract_timestamp: OverflowError/OSError/ValueError
_extract_timestamp-->>JsonLogParser: return None (timestamp unset)
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
What does this change do?
JSON log records with numeric timestamps outside the platform datetime range are still returned as parsed entries, with their timestamp left unset.
Why is this needed?
A single malformed or unrepresentable timestamp should not discard an otherwise useful log record or abort parsing the file.
Testing
PYTHONPATH=src pytest -q tests/test_parsers.py -o addopts="" --disable-warnings— 24 passedgit diff --checkDrafted with GPT-5.6 Luna; reviewed by the repository owner.
Summary by Sourcery
Handle JSON log records whose numeric timestamps are outside the platform datetime range without discarding the entries.
Bug Fixes:
Tests: