fix(clp-s::log_converter): Make timezone offset optional in timezone regex (fixes #1952).#2134
Conversation
WalkthroughModified the timestamp schema regex pattern in the log converter to make fractional seconds an optional component directly following the seconds field, rather than being conditionally tied to timezone or subsequent segments. This alters which timestamp formats are accepted during log parsing. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@components/core/src/clp_s/log_converter/LogConverter.cpp`:
- Around line 32-33: Add a unit test that verifies the regex in LogConverter
(the multi-line raw string literal that matches timestamps, including the Z
timezone branch) correctly accepts and parses timestamps ending with a bare "Z"
(e.g. "2023-12-01T12:34:56Z"); call the same public method used in production
(e.g., LogConverter::convertLine or LogConverter::parseTimestamp) with a sample
log containing a Z-only timezone and assert the timestamp is
recognized/converted to UTC and no error is produced; place the test alongside
other LogConverter tests so future changes to the regex literal will be caught
by CI.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: dd60f952-fc94-48d8-a9c4-24efc06c7edb
📒 Files selected for processing (1)
components/core/src/clp_s/log_converter/LogConverter.cpp
| R"((Dec(ember){0,1}))[ /\-]\d{2,4}))[ T:][ 0-9]{2}:[ 0-9]{2}:[ 0-9]{2}([,\.:]\d{1,9}){0,1})" | ||
| R"(([ ]{0,1}(UTC){0,1}([\+\-]\d{2}(:{0,1}\d{2}){0,1}){0,1}Z{0,1}){0,1}))" |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Add a regression test for Z-only timezone timestamps.
The case is manually validated in the PR, but it should be covered by automated tests to avoid future regex regressions.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@components/core/src/clp_s/log_converter/LogConverter.cpp` around lines 32 -
33, Add a unit test that verifies the regex in LogConverter (the multi-line raw
string literal that matches timestamps, including the Z timezone branch)
correctly accepts and parses timestamps ending with a bare "Z" (e.g.
"2023-12-01T12:34:56Z"); call the same public method used in production (e.g.,
LogConverter::convertLine or LogConverter::parseTimestamp) with a sample log
containing a Z-only timezone and assert the timestamp is recognized/converted to
UTC and no error is produced; place the test alongside other LogConverter tests
so future changes to the regex literal will be caught by CI.
| R"((Dec(ember){0,1}))[ /\-]\d{2,4}))[ T:][ 0-9]{2}:[ 0-9]{2}:[ 0-9]{2}([,\.:]\d{1,9}){0,1})" | ||
| R"(([ ]{0,1}(UTC){0,1}([\+\-]\d{2}(:{0,1}\d{2}){0,1}){0,1}Z{0,1}){0,1}))" |
There was a problem hiding this comment.
iiuc, Z is a short term for UTC and it should be mutually exclusive to the UTC offset. Does it make more sense to write in this way (or similar)?
| R"((Dec(ember){0,1}))[ /\-]\d{2,4}))[ T:][ 0-9]{2}:[ 0-9]{2}:[ 0-9]{2}([,\.:]\d{1,9}){0,1})" | |
| R"(([ ]{0,1}(UTC){0,1}([\+\-]\d{2}(:{0,1}\d{2}){0,1}){0,1}Z{0,1}){0,1}))" | |
| R"((Dec(ember){0,1}))[ /\-]\d{2,4}))[ T:][ 0-9]{2}:[ 0-9]{2}:[ 0-9]{2})" | |
| R"(([,\.:]\d{1,9}){0,1}(([ ]{0,1}(UTC){0,1}[\+\-]\d{2}(:{0,1}\d{2}))|(Z)){0,1}))" |
There was a problem hiding this comment.
In practice it isn't mutually exclusive. We see timezones like -00Z in the wild. (Edited to a more common case).
Description
This PR fixes an issue in log-converter where the timezone
Zwasn't accepted as a valid timezone on its own since the timezone regex required a timezone offset in matching timezones.The fix is simply to update the regex to make the offset part of the timezone optional.
Checklist
breaking change.
Validation performed
log-converter:clp-susing the--timestamp-key timestampoption.timestamp < timestamp("2026-03-26T07:03:17,222Z")returned the following result, as expected:Summary by CodeRabbit
Release Notes