:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(jira): parse epoch millis changelog watermark (#123173)
Tom Owers28bf3934538a
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/jira/jira.py b/products/warehouse_sources/backend/temporal/data_imports/sources/jira/jira.pyindex 3a6629883595..d27f12733446 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/jira/jira.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/jira/jira.py@@ -84,14 +84,20 @@ def _auth_headers(email: str, api_token: str) -> dict[str, str]:return {"Authorization": f"Basic {token}", "Accept": "application/json"}-def _format_jql_datetime(value: Any) -> str:+def _parse_datetime(value: Any) -> datetime:if isinstance(value, datetime):- dt = value- elif isinstance(value, date):- dt = datetime.combine(value, datetime.min.time())- else:- dt = datetime.fromisoformat(str(value).replace("Z", "+00:00"))- return (dt - INCREMENTAL_LOOKBACK).strftime(JQL_DATETIME_FORMAT)+ return value+ if isinstance(value, date):+ return datetime.combine(value, datetime.min.time())+ # ``/changelog/bulkfetch`` returns ``created`` as epoch milliseconds, so the issue_changelogs+ # watermark is a number. ``fromisoformat`` misreads a digit string as a compact ISO date.+ if isinstance(value, int | float) or str(value).isdigit():+ return datetime.fromtimestamp(0, UTC) + timedelta(milliseconds=int(value))+ return datetime.fromisoformat(str(value).replace("Z", "+00:00"))+++def _format_jql_datetime(value: Any) -> str:+ return (_parse_datetime(value) - INCREMENTAL_LOOKBACK).strftime(JQL_DATETIME_FORMAT)def _build_issues_jql(incremental_field: str | None, last_value: Any) -> str:@@ -167,12 +173,7 @@ class JiraWorklogPaginator(JSONResponseCursorPaginator):def _to_epoch_millis(value: Any) -> int:- if isinstance(value, datetime):- dt = value- elif isinstance(value, date):- dt = datetime.combine(value, datetime.min.time())- else:- dt = datetime.fromisoformat(str(value).replace("Z", "+00:00"))+ dt = _parse_datetime(value)if dt.tzinfo is None:dt = dt.replace(tzinfo=UTC)return int(dt.timestamp() * 1000)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/jira/tests/test_jira.py b/products/warehouse_sources/backend/temporal/data_imports/sources/jira/tests/test_jira.pyindex 351130732d87..135a41aa50bc 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/jira/tests/test_jira.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/jira/tests/test_jira.py@@ -52,6 +52,8 @@ class TestFormatJqlDatetime:("date", date(2026, 3, 4), "2026-03-03 00:00"),("iso_string", "2026-03-04T02:58:14+00:00", "2026-03-03 02:58"),("iso_string_z", "2026-03-04T02:58:14Z", "2026-03-03 02:58"),+ ("epoch_millis", 1772593094000, "2026-03-03 02:58"),+ ("epoch_millis_string", "1772593094000", "2026-03-03 02:58"),])def test_format_jql_datetime(self, _name: str, value: Any, expected: str) -> None:@@ -389,6 +391,13 @@ class TestIssueChangelogs:'updated >= "2026-03-03 02:58" ORDER BY updated ASC',["recent"],),+ # The stored watermark is the max ``created``, which bulkfetch returns as epoch milliseconds.+ (+ "incremental_epoch_millis_watermark",+ {"incremental_field": "created", "db_incremental_field_last_value": 1772593080000},+ 'updated >= "2026-03-03 02:58" ORDER BY updated ASC',+ ["recent"],+ ),])def test_incremental_shapes_jql_and_drops_history_before_the_window(@@ -406,8 +415,8 @@ class TestIssueChangelogs:{"issueId": "10","changeHistories": [- {"id": "old", "created": "2026-03-03T02:57:00.000+0000"},- {"id": "recent", "created": "2026-03-03T02:58:00.000+0000"},+ {"id": "old", "created": 1772506620000},+ {"id": "recent", "created": 1772506680000},],}]