Skip to content

fix(common/time_utils): correct None/empty timestamp fallback and ISO 8601 parsing - #16483

Merged
yuzhichang merged 3 commits into
infiniflow:mainfrom
Harsh23Kashyap:Harsh23Kashyap/fix/time-utils-edgecases
Jun 30, 2026
Merged

yuzhichang merged 3 commits into
infiniflow:mainfrom
Harsh23Kashyap:Harsh23Kashyap/fix/time-utils-edgecases

Conversation

@Harsh23Kashyap

Copy link
Copy Markdown
Collaborator

Recovery PR for #16173 after the fork branch was accidentally reset during rewrite-cleanup.

Cherry-picked onto current main:

  • fix(common/time_utils): correct fallback timestamp and ISO-8601 normalization
  • fix(common/time_utils): preserve zero timestamps and mark regression tests
  • test(common/time_utils): make fallback assertions deterministic

Supersedes closed #16173 — same branch Harsh23Kashyap/fix/time-utils-edgecases, rebuilt per @yuzhichang recovery steps in #16173 (comment)

@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. 🌈 python Pull requests that update Python code 🐞 bug Something isn't working, pull request that fix bug. 🧪 test Pull requests that update test cases. labels Jun 30, 2026
@Harsh23Kashyap
Harsh23Kashyap force-pushed the Harsh23Kashyap/fix/time-utils-edgecases branch from d672ebf to f6bfbaa Compare June 30, 2026 06:14
@Harsh23Kashyap

Copy link
Copy Markdown
Collaborator Author

Recovery for accidentally closed #16173. Branch rebuilt on current main with the three commits from #16173 (comment). Please add the ci label when convenient.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 56faaade-af95-498c-b807-a52e9f7a4b63

📥 Commits

Reviewing files that changed from the base of the PR and between f6bfbaa and db45f52.

📒 Files selected for processing (2)
  • common/time_utils.py
  • test/unit_test/common/test_time_utils.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • common/time_utils.py
  • test/unit_test/common/test_time_utils.py

📝 Walkthrough

Walkthrough

Two bug fixes in common/time_utils.py: timestamp_to_date now explicitly checks for None or "" and falls back to current_timestamp() with a debug log; format_iso_8601_to_ymd_hms now parses directly with dateutil.isoparse without a conditional re-parse. Regression tests cover both behaviors.

Timestamp fallback and ISO 8601 parsing fixes

Layer / File(s) Summary
timestamp_to_date fallback and format_iso_8601_to_ymd_hms simplification
common/time_utils.py
timestamp_to_date switches from a broad falsy check with time.time() to an explicit None/"" guard using current_timestamp() and a debug log. format_iso_8601_to_ymd_hms drops the conditional re-parse branch and always formats from a single dateutil.isoparse call.
Regression tests for fallback and ISO parsing
test/unit_test/common/test_time_utils.py
Adds format_iso_8601_to_ymd_hms import and two new test classes: one monkeypatches current_timestamp to assert None/"" fallback and 0-as-epoch behavior; another asserts correct conversion for UTC Z, +00:00 offset, ordinal-date forms, and passthrough for invalid input.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 A zero is real, don't treat it as None,
And "" is empty — the fallback should run.
One parse with isoparse, no second guess,
Ordinal dates handled with bunny finesse.
The epoch stays honest, the logs tell the tale! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main fixes in common/time_utils for timestamp fallback and ISO 8601 parsing.
Description check ✅ Passed The description gives recovery context, scope, and linked issue references, though it does not use the template's exact Summary heading.
Linked Issues check ✅ Passed The code and tests address both linked bugs: None/empty fallbacks now use current_timestamp, and ISO 8601 parsing uses dateutil.isoparse once.
Out of Scope Changes check ✅ Passed The changes stay within the time_utils fix and its regression tests, with no unrelated code introduced.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@yuzhichang yuzhichang added the ci Continue Integration label Jun 30, 2026

@yuzhichang yuzhichang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jun 30, 2026
@yuzhichang yuzhichang added ci Continue Integration and removed ci Continue Integration labels Jun 30, 2026
@codecov

codecov Bot commented Jun 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (3633d08) to head (4117940).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #16483   +/-   ##
=======================================
  Coverage   93.16%   93.16%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          668      668           
  Misses         29       29           
  Partials       20       20           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Harsh Kashyap and others added 3 commits June 30, 2026 19:14
…lization

Use millisecond current timestamps when input is empty and parse ISO-8601 values through dateutil once so ordinal forms are normalized instead of being silently returned unchanged. Add regression tests for None/empty fallback behavior and ordinal ISO parsing.

Co-authored-by: Cursor <[email protected]>
…tests

Treat only None/empty string as missing input so timestamp 0 is handled as a valid epoch value, and add fallback debug logging for observability. Add p2 priority markers to new regression suites plus a guard test proving zero is not treated as missing.

Co-authored-by: Cursor <[email protected]>
Replace wall-clock range assertions in fallback tests with fixed current_timestamp monkeypatching so the suite remains stable under CI scheduler delays while still verifying fallback behavior exactly.

Co-authored-by: Cursor <[email protected]>
@Harsh23Kashyap
Harsh23Kashyap force-pushed the Harsh23Kashyap/fix/time-utils-edgecases branch from 4117940 to db45f52 Compare June 30, 2026 13:44
@yuzhichang
yuzhichang merged commit 45fc7fe into infiniflow:main Jun 30, 2026
2 of 3 checks passed
@Harsh23Kashyap
Harsh23Kashyap deleted the Harsh23Kashyap/fix/time-utils-edgecases branch June 30, 2026 16:54
yuzhichang pushed a commit that referenced this pull request Jul 2, 2026
### Summary

Port the following PRs to GO in this PR

#14210
#14641
#15220
#15228
#15384
#15754
#16413
#16483
#16419
#16361   
#16050
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration lgtm This PR has been approved by a maintainer 🌈 python Pull requests that update Python code size:S This PR changes 10-29 lines, ignoring generated files. 🧪 test Pull requests that update test cases.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants