Skip to content

: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.

fix(warehouse): bound Jira full-sync JQL to avoid 400 (#67649)

Luke Beltonbdc03cfd483b
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.py
index 2eaab31d05b1..f090e7347e54 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
@@ -63,11 +63,16 @@ def _format_jql_datetime(value: Any) -> str:
return (dt - INCREMENTAL_LOOKBACK).strftime(JQL_DATETIME_FORMAT)
+# The enhanced ``/search/jql`` endpoint rejects unbounded queries (400 "Unbounded JQL queries are not
+# allowed here"). On a full sync there's no watermark, so anchor to an epoch floor to keep the query bounded
+# while still scanning every issue.
+JQL_FLOOR_DATETIME = "1970-01-01 00:00"
+
+
def _build_issues_jql(incremental_field: str | None, last_value: Any) -> str:
field = incremental_field or "updated"
- where = f'{field} >= "{_format_jql_datetime(last_value)}"' if last_value else ""
- order = f"ORDER BY {field} ASC"
- return f"{where} {order}".strip()
+ since = _format_jql_datetime(last_value) if last_value else JQL_FLOOR_DATETIME
+ return f'{field} >= "{since}" ORDER BY {field} ASC'
def _extract_items(data: Any, data_key: str | None) -> list[dict[str, Any]]:
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.py
index d57455c4f473..69fb57e22171 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
@@ -72,8 +72,9 @@ class TestFormatJqlDatetime:
class TestBuildIssuesJql:
- def test_no_last_value_orders_ascending(self) -> None:
- assert _build_issues_jql("updated", None) == "ORDER BY updated ASC"
+ def test_no_last_value_bounds_with_epoch_floor(self) -> None:
+ # ``/search/jql`` 400s on unbounded queries, so a full sync must still carry a lower bound.
+ assert _build_issues_jql("updated", None) == 'updated >= "1970-01-01 00:00" ORDER BY updated ASC'
def test_with_last_value_filters_and_orders(self) -> None:
jql = _build_issues_jql("updated", datetime(2026, 3, 4, 2, 58))
@@ -84,7 +85,7 @@ class TestBuildIssuesJql:
assert jql == 'created >= "2026-03-03 02:58" ORDER BY created ASC'
def test_none_field_defaults_to_updated(self) -> None:
- assert _build_issues_jql(None, None) == "ORDER BY updated ASC"
+ assert _build_issues_jql(None, None) == 'updated >= "1970-01-01 00:00" ORDER BY updated ASC'
class TestExtractItems: