Skip to content

fix(logstore): normalize workflow datetimes to UTC - #40967

Closed
weike-zhang wants to merge 2 commits into
langgenius:mainfrom
weike-zhang:fix/logstore-utc-normalization
Closed

fix(logstore): normalize workflow datetimes to UTC#40967
weike-zhang wants to merge 2 commits into
langgenius:mainfrom
weike-zhang:fix/logstore-utc-normalization

Conversation

@weike-zhang

Copy link
Copy Markdown
Contributor

Refs #40943

What

Normalize LogStore workflow timestamps to naive UTC in both workflow run and workflow node execution repositories.

Why

The current code uses local-time datetime constructors for epoch and missing-value branches, which can shift timestamps by host timezone and produce incorrect or even negative elapsed times.

How

  • Use naive_utc_now() for missing timestamps
  • Use ensure_naive_utc(datetime.fromisoformat(...)) for ISO strings
  • Use datetime.fromtimestamp(..., tz=UTC).replace(tzinfo=None) for epoch values
  • Add a regression test for mixed timestamp inputs

Verification

  • uv run --project api pytest -o addopts='--import-mode=importlib' api/tests/unit_tests/extensions/logstore/repositories/test_logstore_api_workflow_run_repository.py api/tests/unit_tests/extensions/logstore/repositories/test_logstore_api_workflow_node_execution_repository.py api/tests/unit_tests/extensions/logstore/repositories/test_logstore_workflow_node_execution_repository.py

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Aug 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 59.71% 59.71% +0.00%
Strict coverage 59.29% 59.29% +0.00%
Typed symbols 39,742 39,744 +2
Untyped symbols 27,010 27,010 0
Modules 3171 3172 +1

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Aug 19, 2026
@asukaminato0721
asukaminato0721 added this pull request to the merge queue Aug 19, 2026
@asukaminato0721
asukaminato0721 removed this pull request from the merge queue due to a manual request Aug 19, 2026
@weike-zhang
weike-zhang force-pushed the fix/logstore-utc-normalization branch from f9dd61c to 14abd85 Compare August 20, 2026 05:27
@weike-zhang

Copy link
Copy Markdown
Contributor Author

The Web Full-Stack E2E failure is a CI infrastructure timeout: the Install Playwright browsers for core E2E step timed out after 15 minutes (https://github.com/langgenius/dify/actions/runs/32235372870/job/96014359616), before any test ran. Fork PRs can't re-run workflow runs without repo admin. Could a maintainer please re-run the failed job?

@weike-zhang

Copy link
Copy Markdown
Contributor Author

This fix is already merged upstream via #40947 (identical changes to the workflow run and node-execution repositories). Closing this PR as superseded — no further action needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants