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.

feat(warehouse_sources): support monday API version 2026-07 (#113223)

Tom Owers090d0375fc6c
diff --git a/.agents/skills/warehouse-source-new-version/SKILL.md b/.agents/skills/warehouse-source-new-version/SKILL.md
index f057767adc90..d9817f734e87 100644
--- a/.agents/skills/warehouse-source-new-version/SKILL.md
+++ b/.agents/skills/warehouse-source-new-version/SKILL.md
@@ -84,6 +84,7 @@ The opposite gap also occurs: a reference rendered from one version-blind OpenAP
## Common pitfalls
- Vendor version labels are opaque: `"2026-02-25.clover"`, `"v21.0"`, `"2022-06-28"`. Copy them exactly; never normalize, sort, or parse.
+- A framework label can differ from the wire version it sends (e.g. a `"v2"` label that sends a dated version header). A vendor deprecation names the wire version, so deprecate and repin the framework label that sends it. Add the successor under the vendor's own label, never by repointing the old label's header.
- A source's per-endpoint URL versions (a hardcoded `/v2/...`, `/v3/...` in the endpoint config) are independent of the framework's source-level version label. A source may already call the vendor's newest per-resource routes while still carrying the `UNVERSIONED_API_VERSION` default — so a version-add can be correct as declaration-only even when the vendor's own version numbers look far apart. Diff what the source actually requests, not the vendor's headline version.
- When a vendor selects versions with a per-endpoint query param and _requires_ it on some endpoints regardless of version, those endpoints must send the selector under every pin, the legacy one included — they are version-independent even though the selector value matches the new label, and gating them on the resolved pin breaks the old pin. Gate on the pin only endpoints where the selector is optional and merely enriches the response (extra fields under the new version); those are the genuine divergence.
- A change the vendor calls "breaking" (e.g. resource ids migrating int→string) still needs no per-version branch when the source only passes the affected values through opaquely — a primary key whose _column name_ is stable (type auto-inferred), cursors forwarded verbatim. The version still has to exist (the gate passed on a real divergence), but branch the request path only where the change hits a surface you hardcode: column hints, a parsed cursor, a typed primary key.
diff --git a/products/warehouse_sources/backend/migrations/0174_repin_monday_api_version_2026_07.py b/products/warehouse_sources/backend/migrations/0174_repin_monday_api_version_2026_07.py
new file mode 100644
index 000000000000..332d56db64e8
--- /dev/null
+++ b/products/warehouse_sources/backend/migrations/0174_repin_monday_api_version_2026_07.py
@@ -0,0 +1,31 @@
+from django.db import migrations
+
+# monday.com deprecated API version 2024-10 (the framework "v2" label) on 2026-02-15. monday does not
+# reject the retired header: it answers with its maintenance version, so a "v2" pin silently stops
+# selecting the version it names. Every query this source sends is valid under 2026-07, and every
+# table is full refresh, so the repin needs no data or schema transform.
+# This moves the source-level pin only; schema-level `ExternalDataSchema.api_version` overrides are
+# user-managed and intentionally left untouched. NULL pins already resolve to the new default.
+SOURCE_TYPE = "Monday"
+DEPRECATED_VERSION = "v2"
+NEW_VERSION = "2026-07"
+
+
+def repin_monday_to_2026_07(apps, schema_editor):
+ ExternalDataSource = apps.get_model("warehouse_sources", "ExternalDataSource")
+
+ # One row per configured source, so a single bulk update is quick. Idempotent: a second run finds
+ # no v2 monday.com rows.
+ ExternalDataSource.objects.filter(source_type=SOURCE_TYPE, api_version=DEPRECATED_VERSION).update(
+ api_version=NEW_VERSION
+ )
+
+
+class Migration(migrations.Migration):
+ dependencies = [("warehouse_sources", "0173_repair_legacy_full_sync_type")]
+
+ operations = [
+ # Reverse is a no-op: once repinned, 2026-07 rows are indistinguishable from natively-created ones,
+ # so a blanket downgrade would clobber legitimate 2026-07 pins made after this ran.
+ migrations.RunPython(repin_monday_to_2026_07, migrations.RunPython.noop, elidable=True),
+ ]
diff --git a/products/warehouse_sources/backend/migrations/max_migration.txt b/products/warehouse_sources/backend/migrations/max_migration.txt
index 403d85f71b17..a5e595cc5ef1 100644
--- a/products/warehouse_sources/backend/migrations/max_migration.txt
+++ b/products/warehouse_sources/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0173_repair_legacy_full_sync_type
+0174_repin_monday_api_version_2026_07
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/monday/monday.py b/products/warehouse_sources/backend/temporal/data_imports/sources/monday/monday.py
index 736908ebd40e..7e15ac784d2a 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/monday/monday.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/monday/monday.py
@@ -10,8 +10,14 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.typ
from products.warehouse_sources.backend.temporal.data_imports.sources.monday.settings import MONDAY_ENDPOINTS
MONDAY_API_URL = "https://api.monday.com/v2"
-# Pinned GA API version (monday releases quarterly versions).
-MONDAY_API_VERSION = "2024-10"
+# Framework version labels. monday releases a dated version every quarter and selects it with the
+# `API-Version` header; "v2" predates dated labels and keeps sending the header it shipped with.
+MONDAY_VERSION_V2 = "v2"
+MONDAY_VERSION_2026_07 = "2026-07"
+MONDAY_API_VERSION_HEADERS: dict[str, str] = {
+ MONDAY_VERSION_V2: "2024-10",
+ MONDAY_VERSION_2026_07: "2026-07",
+}
# Boards/users page size; items_page caps at 500.
PAGE_SIZE = 100
ITEMS_PAGE_SIZE = 500
@@ -118,9 +124,20 @@ class MondayGraphQLError(Exception):
pass
-def _get_session(api_token: str) -> requests.Session:
+def _api_version_header(api_version: str) -> str:
+ # An unmapped label must not fall through to a request without the header: monday then serves
+ # whatever version is current, which moves under a pinned source.
+ try:
+ return MONDAY_API_VERSION_HEADERS[api_version]
+ except KeyError:
+ raise ValueError(
+ f"Unsupported monday.com API version {api_version!r}; supported: {tuple(MONDAY_API_VERSION_HEADERS)}"
+ )
+
+
+def _get_session(api_token: str, api_version: str) -> requests.Session:
return make_tracked_session(
- headers={"Authorization": api_token, "API-Version": MONDAY_API_VERSION},
+ headers={"Authorization": api_token, "API-Version": _api_version_header(api_version)},
redact_values=(api_token,),
)
@@ -172,10 +189,10 @@ class _NoopLogger:
return None
-def validate_credentials(api_token: str) -> bool:
+def validate_credentials(api_token: str, api_version: str) -> bool:
"""Confirm the API token is valid with a cheap `me` query."""
try:
- session = _get_session(api_token)
+ session = _get_session(api_token, api_version)
data = _execute(session, "query { me { id } }", {}, _NoopLogger()) # type: ignore[arg-type]
return bool((data.get("me") or {}).get("id"))
except Exception:
@@ -186,8 +203,9 @@ def get_rows(
api_token: str,
endpoint: str,
logger: FilteringBoundLogger,
+ api_version: str,
) -> Iterator[list[dict[str, Any]]]:
- session = _get_session(api_token)
+ session = _get_session(api_token, api_version)
@retry(
retry=retry_if_exception_type((MondayRetryableError, requests.ReadTimeout, requests.ConnectionError)),
@@ -246,6 +264,7 @@ def monday_source(
api_token: str,
endpoint: str,
logger: FilteringBoundLogger,
+ api_version: str,
) -> SourceResponse:
config = MONDAY_ENDPOINTS[endpoint]
@@ -255,6 +274,7 @@ def monday_source(
api_token=api_token,
endpoint=endpoint,
logger=logger,
+ api_version=api_version,
),
primary_keys=config.primary_keys,
partition_count=1,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/monday/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/monday/source.py
index 377dadb5bf2f..5fa646161c99 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/monday/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/monday/source.py
@@ -1,3 +1,4 @@
+from datetime import date
from typing import Optional, cast
from products.warehouse_sources.backend.facade.source_config import (
@@ -7,7 +8,11 @@ from products.warehouse_sources.backend.facade.source_config import (
SourceFieldInputConfig,
SourceFieldInputConfigType,
)
-from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, SimpleSource
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import (
+ FieldType,
+ SimpleSource,
+ VersionDeprecation,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (
CanonicalDescriptions,
)
@@ -16,6 +21,8 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.sch
from products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceInputs, SourceResponse
from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.monday import MondaySourceConfig
from products.warehouse_sources.backend.temporal.data_imports.sources.monday.monday import (
+ MONDAY_VERSION_2026_07,
+ MONDAY_VERSION_V2,
monday_source,
validate_credentials as validate_monday_credentials,
)
@@ -25,9 +32,12 @@ from products.warehouse_sources.backend.types import ExternalDataSourceType
@SourceRegistry.register
class MondaySource(SimpleSource[MondaySourceConfig]):
- supported_versions = ("v2",)
- default_version = "v2"
+ supported_versions = (MONDAY_VERSION_V2, MONDAY_VERSION_2026_07)
+ default_version = MONDAY_VERSION_2026_07
api_docs_url = "https://developer.monday.com/api-reference"
+ # "v2" sends `API-Version: 2024-10`, which monday deprecated on this date. monday now answers it with
+ # its maintenance version instead of rejecting it, so a v2 pin no longer selects what it names.
+ deprecated_versions = (VersionDeprecation(version=MONDAY_VERSION_V2, sunset_at=date(2026, 2, 15)),)
lists_tables_without_credentials = True # static endpoint catalog — safe for public docs
@@ -121,7 +131,7 @@ You can find your personal API token in monday.com under your avatar > Developer
schema_name: Optional[str] = None,
api_version: str | None = None,
) -> tuple[bool, str | None]:
- if validate_monday_credentials(config.api_token):
+ if validate_monday_credentials(config.api_token, self.resolve_api_version(api_version)):
return True, None
return False, "Invalid monday.com API token"
@@ -131,4 +141,5 @@ You can find your personal API token in monday.com under your avatar > Developer
api_token=config.api_token,
endpoint=inputs.schema_name,
logger=inputs.logger,
+ api_version=self.resolve_api_version(inputs.api_version),
)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/monday/tests/test_monday.py b/products/warehouse_sources/backend/temporal/data_imports/sources/monday/tests/test_monday.py
index 1c54a1e27504..6fe1e62475ab 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/monday/tests/test_monday.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/monday/tests/test_monday.py
@@ -5,6 +5,8 @@ from unittest import mock
from products.warehouse_sources.backend.temporal.data_imports.sources.monday.monday import (
ITEMS_PAGE_SIZE,
+ MONDAY_VERSION_2026_07,
+ MONDAY_VERSION_V2,
PAGE_SIZE,
MondayGraphQLError,
MondayRetryableError,
@@ -15,6 +17,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.monday.mon
from products.warehouse_sources.backend.temporal.data_imports.sources.monday.settings import ENDPOINTS, MONDAY_ENDPOINTS
_MODULE = "products.warehouse_sources.backend.temporal.data_imports.sources.monday.monday"
+API_VERSION = MONDAY_VERSION_2026_07
def _response(data: dict[str, Any], errors: list[dict[str, Any]] | None = None) -> mock.MagicMock:
@@ -32,22 +35,22 @@ class TestValidateCredentials:
@mock.patch(f"{_MODULE}.make_tracked_session")
def test_valid_when_me_returns_id(self, mock_session):
mock_session.return_value.post.return_value = _response({"me": {"id": "user-1"}})
- assert validate_credentials("token") is True
+ assert validate_credentials("token", API_VERSION) is True
@mock.patch(f"{_MODULE}.make_tracked_session")
def test_invalid_when_me_is_empty(self, mock_session):
mock_session.return_value.post.return_value = _response({"me": None})
- assert validate_credentials("token") is False
+ assert validate_credentials("token", API_VERSION) is False
@mock.patch(f"{_MODULE}.make_tracked_session")
def test_invalid_on_graphql_errors(self, mock_session):
mock_session.return_value.post.return_value = _response({}, errors=[{"message": "Not Authenticated"}])
- assert validate_credentials("token") is False
+ assert validate_credentials("token", API_VERSION) is False
@mock.patch(f"{_MODULE}.make_tracked_session")
def test_invalid_on_exception(self, mock_session):
mock_session.return_value.post.side_effect = Exception("boom")
- assert validate_credentials("token") is False
+ assert validate_credentials("token", API_VERSION) is False
class TestGetRowsPaged:
@@ -59,7 +62,7 @@ class TestGetRowsPaged:
_response({"boards": [{"id": "last"}]}),
]
- batches = list(get_rows("token", "boards", mock.MagicMock()))
+ batches = list(get_rows("token", "boards", mock.MagicMock(), API_VERSION))
assert len(batches) == 2
first_vars = mock_session.return_value.post.call_args_list[0].kwargs["json"]["variables"]
@@ -72,7 +75,7 @@ class TestGetRowsPaged:
mock_session.return_value.post.return_value = _response({}, errors=[{"message": "Field not found"}])
with pytest.raises(MondayGraphQLError):
- list(get_rows("token", "users", mock.MagicMock()))
+ list(get_rows("token", "users", mock.MagicMock(), API_VERSION))
@mock.patch("time.sleep")
@mock.patch(f"{_MODULE}.make_tracked_session")
@@ -82,7 +85,7 @@ class TestGetRowsPaged:
_response({"users": [{"id": "1"}]}),
]
- batches = list(get_rows("token", "users", mock.MagicMock()))
+ batches = list(get_rows("token", "users", mock.MagicMock(), API_VERSION))
assert batches == [[{"id": "1"}]]
assert mock_session.return_value.post.call_count == 2
@@ -93,7 +96,7 @@ class TestGetRowsPaged:
mock_session.return_value.post.return_value = _response({}, errors=[{"message": "Internal Server Error"}])
with pytest.raises(MondayRetryableError):
- list(get_rows("token", "users", mock.MagicMock()))
+ list(get_rows("token", "users", mock.MagicMock(), API_VERSION))
@mock.patch("time.sleep")
@mock.patch(f"{_MODULE}.make_tracked_session")
@@ -104,20 +107,34 @@ class TestGetRowsPaged:
_response({"users": [{"id": "1"}]}),
]
- batches = list(get_rows("token", "users", mock.MagicMock()))
+ batches = list(get_rows("token", "users", mock.MagicMock(), API_VERSION))
assert batches == [[{"id": "1"}]]
assert mock_session.return_value.post.call_count == 2
+ @pytest.mark.parametrize(
+ "api_version, expected_header",
+ [
+ (MONDAY_VERSION_V2, "2024-10"),
+ (MONDAY_VERSION_2026_07, "2026-07"),
+ ],
+ )
@mock.patch(f"{_MODULE}.make_tracked_session")
- def test_requests_carry_token_and_api_version(self, mock_session):
+ def test_requests_carry_token_and_pinned_api_version(self, mock_session, api_version, expected_header):
mock_session.return_value.post.return_value = _response({"users": []})
- list(get_rows("token", "users", mock.MagicMock()))
+ list(get_rows("token", "users", mock.MagicMock(), api_version))
headers = mock_session.call_args.kwargs["headers"]
assert headers["Authorization"] == "token"
- assert headers["API-Version"]
+ assert headers["API-Version"] == expected_header
+
+ @mock.patch(f"{_MODULE}.make_tracked_session")
+ def test_unknown_api_version_is_rejected_instead_of_sent_without_header(self, mock_session):
+ with pytest.raises(ValueError, match="Unsupported monday.com API version"):
+ list(get_rows("token", "users", mock.MagicMock(), "2024-10"))
+
+ mock_session.assert_not_called()
class TestGetRowsItems:
@@ -130,7 +147,7 @@ class TestGetRowsItems:
_response({"next_items_page": {"cursor": None, "items": [{"id": "tail"}]}}),
]
- batches = list(get_rows("token", "items", mock.MagicMock()))
+ batches = list(get_rows("token", "items", mock.MagicMock(), API_VERSION))
flat = [item for batch in batches for item in batch]
assert len(flat) == ITEMS_PAGE_SIZE + 1
@@ -145,7 +162,7 @@ class TestGetRowsItems:
_response({"boards": [{"items_page": {"cursor": None, "items": [{"id": "only"}]}}]}),
]
- batches = list(get_rows("token", "items", mock.MagicMock()))
+ batches = list(get_rows("token", "items", mock.MagicMock(), API_VERSION))
assert [item["id"] for batch in batches for item in batch] == ["only"]
assert mock_session.return_value.post.call_count == 2
@@ -157,14 +174,14 @@ class TestGetRowsItems:
_response({"boards": []}),
]
- assert list(get_rows("token", "items", mock.MagicMock())) == []
+ assert list(get_rows("token", "items", mock.MagicMock(), API_VERSION)) == []
class TestMondaySourceResponse:
@pytest.mark.parametrize("endpoint", list(ENDPOINTS))
def test_response_metadata_per_endpoint(self, endpoint):
config = MONDAY_ENDPOINTS[endpoint]
- response = monday_source("token", endpoint, mock.MagicMock())
+ response = monday_source("token", endpoint, mock.MagicMock(), API_VERSION)
assert response.name == endpoint
assert response.primary_keys == config.primary_keys
@@ -173,5 +190,5 @@ class TestMondaySourceResponse:
assert response.partition_keys is None
def test_items_have_composite_primary_key(self):
- response = monday_source("token", "items", mock.MagicMock())
+ response = monday_source("token", "items", mock.MagicMock(), API_VERSION)
assert response.primary_keys == ["_board_id", "id"]
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/monday/tests/test_monday_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/monday/tests/test_monday_source.py
index 5f3d5b216439..7e237e514a34 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/monday/tests/test_monday_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/monday/tests/test_monday_source.py
@@ -1,8 +1,15 @@
+from collections.abc import Iterable
+from typing import Any, cast
+
import pytest
from unittest import mock
from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import error_message_matches
from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.monday import MondaySourceConfig
+from products.warehouse_sources.backend.temporal.data_imports.sources.monday.monday import (
+ MONDAY_VERSION_2026_07,
+ MONDAY_VERSION_V2,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.monday.settings import ENDPOINTS
from products.warehouse_sources.backend.temporal.data_imports.sources.monday.source import MondaySource
@@ -64,20 +71,42 @@ class TestMondaySource:
assert self.source.get_schemas(self.config, self.team_id, names=["nope"]) == []
@pytest.mark.parametrize(
- "mock_return, expected_valid, expected_message",
+ "mock_return, expected_valid, expected_message, api_version, expected_api_version",
[
- (True, True, None),
- (False, False, "Invalid monday.com API token"),
+ (True, True, None, None, MONDAY_VERSION_2026_07),
+ (True, True, None, MONDAY_VERSION_V2, MONDAY_VERSION_V2),
+ (False, False, "Invalid monday.com API token", None, MONDAY_VERSION_2026_07),
],
)
@mock.patch(
"products.warehouse_sources.backend.temporal.data_imports.sources.monday.source.validate_monday_credentials"
)
- def test_validate_credentials(self, mock_validate, mock_return, expected_valid, expected_message):
+ def test_validate_credentials(
+ self, mock_validate, mock_return, expected_valid, expected_message, api_version, expected_api_version
+ ):
mock_validate.return_value = mock_return
- is_valid, error_message = self.source.validate_credentials(self.config, self.team_id)
+ is_valid, error_message = self.source.validate_credentials(self.config, self.team_id, api_version=api_version)
assert is_valid is expected_valid
assert error_message == expected_message
- mock_validate.assert_called_once_with(self.config.api_token)
+ mock_validate.assert_called_once_with(self.config.api_token, expected_api_version)
+
+ @pytest.mark.parametrize(
+ "pinned_version, expected_header",
+ [
+ (MONDAY_VERSION_V2, "2024-10"),
+ (MONDAY_VERSION_2026_07, "2026-07"),
+ (None, "2026-07"),
+ ],
+ )
+ @mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.monday.monday.make_tracked_session")
+ def test_sync_sends_the_source_pin(self, mock_session, pinned_version, expected_header):
+ mock_session.return_value.post.return_value = mock.MagicMock(
+ status_code=200, ok=True, json=mock.MagicMock(return_value={"data": {"users": []}})
+ )
+ inputs = mock.MagicMock(schema_name="users", api_version=pinned_version)
+
+ list(cast(Iterable[Any], self.source.source_for_pipeline(self.config, inputs).items()))
+
+ assert mock_session.call_args.kwargs["headers"]["API-Version"] == expected_header