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): deprecate Mem0 v1 API version (#86327)

Tom Owers047f596bff2b
diff --git a/products/warehouse_sources/backend/migrations/0154_repin_mem0_api_version.py b/products/warehouse_sources/backend/migrations/0154_repin_mem0_api_version.py
new file mode 100644
index 000000000000..4b93734766ec
--- /dev/null
+++ b/products/warehouse_sources/backend/migrations/0154_repin_mem0_api_version.py
@@ -0,0 +1,34 @@
+from django.db import migrations
+
+# Mem0 dropped the legacy v1 API generation in its 2.0.0 SDK release, so "v1" is now deprecated.
+# For the tables this source reads, our "v1" label and the "v3" default resolve to byte-identical
+# requests (memories on /v3/, entities and events on /v1/ — no version header, no per-version
+# dispatch), so this repin is a pure relabel: it moves existing source-level pins from "v1" to "v3"
+# without changing a single byte on the wire. No data or schema transform is needed.
+MEM0_SOURCE_TYPE = "Mem0"
+OLD_VERSION = "v1"
+NEW_VERSION = "v3"
+
+
+def repin_mem0_v1_to_v3(apps, schema_editor):
+ ExternalDataSource = apps.get_model("warehouse_sources", "ExternalDataSource")
+
+ # Only the source-level pin is touched. Schema-level `ExternalDataSchema.api_version` overrides
+ # are user-managed (a customer intentionally pinned that schema) and are left alone — the
+ # schema-level deprecation warning prompts the user to migrate those.
+ #
+ # NULL pins already resolve to the source's `default_version` ("v3"), so they need no update.
+ # Matching only `api_version="v1"` keeps this idempotent: a second run matches nothing.
+ ExternalDataSource.objects.filter(source_type=MEM0_SOURCE_TYPE, api_version=OLD_VERSION).update(
+ api_version=NEW_VERSION
+ )
+
+
+class Migration(migrations.Migration):
+ dependencies = [("warehouse_sources", "0153_repin_meta_ads_api_version")]
+
+ operations = [
+ # Reverse is a no-op: once repinned, these rows are indistinguishable from natively-created
+ # ones, so a blanket downgrade would clobber legitimate "v3" pins.
+ migrations.RunPython(repin_mem0_v1_to_v3, migrations.RunPython.noop, elidable=False),
+ ]
diff --git a/products/warehouse_sources/backend/migrations/max_migration.txt b/products/warehouse_sources/backend/migrations/max_migration.txt
index b3e13f787a62..1602eb5aebf0 100644
--- a/products/warehouse_sources/backend/migrations/max_migration.txt
+++ b/products/warehouse_sources/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0153_repin_meta_ads_api_version
+0154_repin_mem0_api_version
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mem0/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mem0/source.py
index 0245b8546b74..91084fc0a625 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mem0/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mem0/source.py
@@ -9,7 +9,12 @@ from posthog.schema import (
SourceFieldInputConfigType,
)
-from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, ResumableSource
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import (
+ UNVERSIONED_API_VERSION,
+ FieldType,
+ ResumableSource,
+ VersionDeprecation,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (
CanonicalDescriptions,
)
@@ -50,6 +55,10 @@ class Mem0Source(ResumableSource[Mem0SourceConfig, Mem0ResumeConfig]):
supported_versions = SUPPORTED_VERSIONS
default_version = DEFAULT_VERSION
+ # Mem0 dropped the legacy v1 API generation in its 2.0.0 SDK release; no calendar sunset date is
+ # published, so this is advisory. The legacy "v1" label and the "v3" default resolve to
+ # byte-identical requests here (see settings.py), so repinning is a pure relabel, not a version move.
+ deprecated_versions = (VersionDeprecation(version=UNVERSIONED_API_VERSION, sunset_at=None),)
@property
def source_type(self) -> ExternalDataSourceType:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mem0/tests/test_mem0_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mem0/tests/test_mem0_source.py
index 477d1c939ac2..bd5d170f9e10 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mem0/tests/test_mem0_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mem0/tests/test_mem0_source.py
@@ -98,6 +98,17 @@ class TestMem0SourceVersions:
assert source.resolve_api_version(None) == MEM0_API_VERSION_V3
assert source.resolve_api_version(UNVERSIONED_API_VERSION) == UNVERSIONED_API_VERSION
+ def test_v1_is_deprecated_without_sunset_and_v3_is_not(self):
+ # The in-product deprecation banner and the repin migration both key off this metadata; the
+ # registry invariant test only checks generic relationships, not the v1-deprecated/v3-current
+ # split or the (absent) sunset date this PR pins.
+ source = Mem0Source()
+
+ deprecation = source.get_version_deprecation(UNVERSIONED_API_VERSION)
+ assert deprecation is not None
+ assert deprecation.sunset_at is None
+ assert source.get_version_deprecation(MEM0_API_VERSION_V3) is None
+
class TestMem0SourceCredentials:
@patch(f"{_SOURCE_MODULE}.validate_mem0_credentials", return_value=True)