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 lovable api version v1 (#126941)

Tom Owers16bff64249d6
diff --git a/.agents/skills/warehouse-source-new-version/SKILL.md b/.agents/skills/warehouse-source-new-version/SKILL.md
index 0a9e1f0c0cef..173e7e2e6b99 100644
--- a/.agents/skills/warehouse-source-new-version/SKILL.md
+++ b/.agents/skills/warehouse-source-new-version/SKILL.md
@@ -73,7 +73,7 @@ The opposite gap also occurs: a reference rendered from one version-blind OpenAP
2. Add the old version to `deprecated_versions` with the vendor's announced sunset date (or `sunset_at=None` if none). When the vendor gives only a month ("supported until January 2027"), use the first day of that month: it is the earliest day the version can stop working, so the warning never comes after the vendor stops serving the version. Never deprecate `default_version` — flip the default to the new version in the same PR. Every other supported label that resolves to the same retiring wire (an alias added by an earlier relabel) shares that sunset: deprecate and repin it too, or its pins hit the shutdown with no warning.
The version to deprecate is the source label whose wire reads the retired path, which can differ from the vendor label in the request. A source on the unversioned `v1` label that reads a vendor `/v2/...` endpoint deprecates and repins `v1`. Never declare the vendor's old label just to deprecate it: no row is pinned to it, and the repin would match nothing.
3. The in-product warning banner and API fields light up automatically from the metadata — zero per-source UI work.
-4. **Deprecated is not migrated.** Existing pins move only when the vendor has announced the version will stop being served (a sunset/removal date). A deprecation without a sunset date is advisory: mark it, leave every existing pin on it fully supported, and write no migration — repinning working customers off a version the vendor still serves is exactly the silent version move the pinning framework exists to prevent. Two narrow cases still repin under an advisory (`sunset_at=None`) deprecation: the deprecated label resolves to a byte-identical request as the new default (a pure alias — no per-version dispatch — so the repin is not a move), or the vendor already errors on the old version (e.g. `410`/`406`) so leaving pins is worse than moving them. A source that sends a per-version header/URL for a version the vendor still serves is neither — stay advisory. A published fixed support window ("each dated version is supported for N months after release") is an announced sunset: compute `sunset_at` from it, even when that date has already passed, and repin. If the docs do not say how the API answers an expired version, add no rejection signature to `get_non_retryable_errors`. Before concluding a vendor publishes no sunset date, find its per-version status table (often on an upgrade-guide page, not the versioning-policy page): a policy page that only describes a generic phase-out timeline is not evidence that no date exists.
+4. **Deprecated is not migrated.** Existing pins move only when the vendor has announced the version will stop being served (a sunset/removal date). A deprecation without a sunset date is advisory: mark it, leave every existing pin on it fully supported, and write no migration — repinning working customers off a version the vendor still serves is exactly the silent version move the pinning framework exists to prevent. Two narrow cases still repin under an advisory (`sunset_at=None`) deprecation: the deprecated label resolves to a byte-identical request as the new default (a pure alias — no per-version dispatch — so the repin is not a move), or the vendor already errors on the old version (e.g. `410`/`406`) so leaving pins is worse than moving them, or the vendor already stopped serving it (a no-selector legacy label whose requests the vendor now resolves to the new label, so the legacy request path already runs against a wire it does not match). A source that sends a per-version header/URL for a version the vendor still serves is neither — stay advisory. A published fixed support window ("each dated version is supported for N months after release") is an announced sunset: compute `sunset_at` from it, even when that date has already passed, and repin. If the docs do not say how the API answers an expired version, add no rejection signature to `get_non_retryable_errors`. Before concluding a vendor publishes no sunset date, find its per-version status table (often on an upgrade-guide page, not the versioning-policy page): a policy page that only describes a generic phase-out timeline is not evidence that no date exists.
5. Only for a sunsetting version: include a **written-not-run** migration script that repins affected `ExternalDataSource` rows (`api_version` column) from the deprecated version to the new one, plus any safe data/schema transforms. It must be idempotent and reviewable, and its reverse must be a no-op — repinned rows are indistinguishable from natively-created ones, so a blanket downgrade would clobber legitimate native pins. Repin only rows explicitly on the deprecated version: when the default is already the target (you are deprecating an old label without flipping the default in this PR), do not also repin NULL pins — they already resolve to the current default, so touching them is redundant churn — and leave other still-served deprecated versions alone. Where migration is lossy or unsafe — including when the new version needs credentials that can't be derived from the stored ones — do not script it: document the manual path in the PR. When only a subset of rows is unsafe (the version diverges for one endpoint that needs a credential others don't), split the cohort: script the repin for the safe rows and exclude the unsafe ones by querying their schemas, documenting only that cohort as manual — don't drop the whole migration to manual because one endpoint can't move. `ExternalDataSchema.deleted` is nullable and NULL means live, so a cohort query excludes `deleted=True` rather than filtering `deleted=False`, which would misread live rows as safe. Whether a column whose _type_ changes across the versions needs a transform is decided by the schema's sync type, not by the type change: a full-refresh schema drops its table before every sync, so the next run rebuilds it under the newly inferred types and the repin alone is enough, while a merge-based schema carries the old type forward and needs a `reset_pipeline` stamp (delta-rs cannot widen in place, and the automatic resync covers only safe numeric widenings). A repin that lands after the sunset does not resume syncs on its own: the vendor's rejection was non-retryable and auto-disabled the affected schemas, so say in the PR that they need re-enabling. Do not execute migrations or backfills; humans review and run them.
6. **Never touch `ExternalDataSchema.api_version` overrides** in migration scripts — they are user-managed by design. The schema-level deprecation warning covers them; the user migrates them from the schema's configuration page.
diff --git a/products/warehouse_sources/backend/migrations/0189_repin_lovable_api_version_2026_09_11.py b/products/warehouse_sources/backend/migrations/0189_repin_lovable_api_version_2026_09_11.py
new file mode 100644
index 000000000000..c6ad5bc324db
--- /dev/null
+++ b/products/warehouse_sources/backend/migrations/0189_repin_lovable_api_version_2026_09_11.py
@@ -0,0 +1,48 @@
+from django.db import migrations
+
+# Lovable lists 2026-09-11 as its only supported API version and serves it to requests without a
+# `Lovable-Version` header. The v1 label sends no header, so v1 pins already receive 2026-09-11
+# responses through a request path built for the old wire.
+#
+# 2026-09-11 has no credit history endpoint, so no source can sync that table today and the repin
+# loses nothing there. Lovable still serves project collaborators, but the source's 2026-09-11 table
+# set does not include them. A source that syncs that table would lose it on repin, so it stays on
+# its pin. The PR documents the manual path for those sources.
+LOVABLE_SOURCE_TYPE = "Lovable"
+OLD_VERSION = "v1"
+NEW_VERSION = "2026-09-11"
+V1_ONLY_TABLES = ("ProjectCollaborators",)
+
+
+def repin_lovable_to_2026_09_11(apps, schema_editor):
+ ExternalDataSource = apps.get_model("warehouse_sources", "ExternalDataSource")
+ ExternalDataSchema = apps.get_model("warehouse_sources", "ExternalDataSchema")
+
+ # `deleted` is nullable, and a NULL row is live, so exclude only rows marked deleted.
+ sources_syncing_v1_only_tables = (
+ ExternalDataSchema.objects.filter(
+ source__source_type=LOVABLE_SOURCE_TYPE,
+ source__api_version=OLD_VERSION,
+ name__in=V1_ONLY_TABLES,
+ should_sync=True,
+ )
+ .exclude(deleted=True)
+ .values("source_id")
+ )
+
+ # Only the source-level pin moves. Schema-level `ExternalDataSchema.api_version` overrides are
+ # user-managed and stay as they are. NULL pins already resolve to the new default. Matching only
+ # the old label keeps this idempotent: a second run matches only the excluded sources.
+ ExternalDataSource.objects.filter(source_type=LOVABLE_SOURCE_TYPE, api_version=OLD_VERSION).exclude(
+ id__in=sources_syncing_v1_only_tables
+ ).update(api_version=NEW_VERSION)
+
+
+class Migration(migrations.Migration):
+ dependencies = [("warehouse_sources", "0188_reset_trunkio_v2_failing_tests")]
+
+ operations = [
+ # Reverse is a no-op: repinned rows are indistinguishable from natively created 2026-09-11
+ # rows, so a blanket downgrade would clobber legitimate pins.
+ migrations.RunPython(repin_lovable_to_2026_09_11, 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 e7bb068fcabc..8464a2894e5d 100644
--- a/products/warehouse_sources/backend/migrations/max_migration.txt
+++ b/products/warehouse_sources/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0188_reset_trunkio_v2_failing_tests
+0189_repin_lovable_api_version_2026_09_11
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/lovable/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/lovable/source.py
index 5b115e9e4924..fddb8411b3ef 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/lovable/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/lovable/source.py
@@ -8,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, ResumableSource
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import (
+ FieldType,
+ ResumableSource,
+ VersionDeprecation,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (
CanonicalDescriptions,
)
@@ -45,6 +49,10 @@ class LovableSource(ResumableSource[LovableSourceConfig, LovableResumeConfig]):
lists_tables_without_credentials = True # static endpoint catalog, safe for public docs
supported_versions = (LOVABLE_API_VERSION_V1, LOVABLE_API_VERSION_2026_09_11)
default_version = LOVABLE_API_VERSION_2026_09_11
+ # Lovable lists 2026-09-11 as its only supported version and serves it to requests without a
+ # `Lovable-Version` header, so v1's request path no longer gets the wire it was built for.
+ # Lovable publishes no retirement date for v1.
+ deprecated_versions = (VersionDeprecation(version=LOVABLE_API_VERSION_V1, sunset_at=None),)
api_docs_url = "https://api.lovable.dev/v1/docs"
@property
diff --git a/products/warehouse_sources/backend/tests/test_migration_repin_lovable_api_version_2026_09_11.py b/products/warehouse_sources/backend/tests/test_migration_repin_lovable_api_version_2026_09_11.py
new file mode 100644
index 000000000000..dc984cab3c89
--- /dev/null
+++ b/products/warehouse_sources/backend/tests/test_migration_repin_lovable_api_version_2026_09_11.py
@@ -0,0 +1,56 @@
+from typing import Any
+
+from posthog.test.base import TestMigrations
+
+
+class TestRepinLovableApiVersion20260911(TestMigrations):
+ migrate_from = "0188_reset_trunkio_v2_failing_tests"
+ migrate_to = "0189_repin_lovable_api_version_2026_09_11"
+
+ def setUpBeforeMigration(self, apps: Any) -> None:
+ ExternalDataSource = apps.get_model("warehouse_sources", "ExternalDataSource")
+ ExternalDataSchema = apps.get_model("warehouse_sources", "ExternalDataSchema")
+
+ def source(source_type: str, api_version: str | None, schemas: list[tuple[str, bool, bool | None]]) -> str:
+ created = ExternalDataSource.objects.create(
+ team_id=self.team.id,
+ source_id="source-id",
+ connection_id="connection-id",
+ status="Completed",
+ source_type=source_type,
+ api_version=api_version,
+ )
+ for name, should_sync, deleted in schemas:
+ ExternalDataSchema.objects.create(
+ team_id=self.team.id,
+ source=created,
+ name=name,
+ should_sync=should_sync,
+ deleted=deleted,
+ api_version="v1" if name == "ProjectPiiLabels" else None,
+ )
+ return str(created.id)
+
+ self.expected = {
+ source("Lovable", "v1", [("Workspaces", True, False), ("WorkspaceCreditHistory", True, False)]): (
+ "2026-09-11"
+ ),
+ source("Lovable", "v1", [("ProjectPiiLabels", True, False), ("ProjectCollaborators", False, False)]): (
+ "2026-09-11"
+ ),
+ source("Lovable", "v1", [("ProjectCollaborators", True, True)]): "2026-09-11",
+ source("Lovable", "v1", [("ProjectCollaborators", True, False)]): "v1",
+ source("Lovable", "v1", [("ProjectCollaborators", True, None)]): "v1",
+ source("Lovable", None, [("Workspaces", True, False)]): None,
+ source("Lovable", "2026-09-11", []): "2026-09-11",
+ source("Langfuse", "v1", []): "v1",
+ }
+
+ def test_repins_only_sources_that_lose_no_synced_table(self) -> None:
+ assert self.apps is not None
+ ExternalDataSource = self.apps.get_model("warehouse_sources", "ExternalDataSource")
+ ExternalDataSchema = self.apps.get_model("warehouse_sources", "ExternalDataSchema")
+
+ pins = dict(ExternalDataSource.objects.filter(id__in=self.expected).values_list("id", "api_version"))
+ assert {str(source_id): pin for source_id, pin in pins.items()} == self.expected
+ assert ExternalDataSchema.objects.get(name="ProjectPiiLabels").api_version == "v1"