: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
feat(warehouse_sources): deprecate lightspeed retail API version 2026-01 (#113212)
Tom Owersdb411f6d3bb2
diff --git a/.agents/skills/warehouse-source-new-version/SKILL.md b/.agents/skills/warehouse-source-new-version/SKILL.mdindex d930545cf3ca..2bee6ba25c91 100644--- a/.agents/skills/warehouse-source-new-version/SKILL.md+++ b/.agents/skills/warehouse-source-new-version/SKILL.md@@ -69,7 +69,7 @@ The opposite gap also occurs: a reference rendered from one version-blind OpenAP## Deprecating a version1. Implement the newer version first (steps above) if not already supported. When the version being sunset is the vendor's **terminal** version (the whole product is discontinued and there is no successor to add), per-version deprecation cannot apply — the framework never deprecates a source's sole/default version, and there is no version to repin to. Don't fabricate a successor or relax the invariant to force the metadata: leave `supported_versions`/`default_version` unchanged, document the vendor sunset and the customer off-ramp (move off the source entirely before shutdown) in the PR, and surface whether a source-level whole-product deprecation surface is warranted for a human to decide.-2. Add the old version to `deprecated_versions` with the vendor's announced sunset date (or `sunset_at=None` if none). Never deprecate `default_version` — flip the default to the new version in the same PR.+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.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.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. 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). Do not execute migrations or backfills; humans review and run them.diff --git a/products/warehouse_sources/backend/migrations/0176_repin_lightspeed_retail_api_version_2026_07.py b/products/warehouse_sources/backend/migrations/0176_repin_lightspeed_retail_api_version_2026_07.pynew file mode 100644index 000000000000..7356ab81651a--- /dev/null+++ b/products/warehouse_sources/backend/migrations/0176_repin_lightspeed_retail_api_version_2026_07.py@@ -0,0 +1,34 @@+from django.db import migrations++# Lightspeed Retail (X-Series) supports the 2026-01 version until January 2027. After that a request+# to it is served by the oldest supported version instead of failing, so the pin silently stops being+# honored. Repin source-level pins onto 2026-07 (the current default). For the endpoints this source+# reads, 2026-04 and 2026-07 only add fields (inventory reorder fields), which the auto-inferred+# schema picks up, so only the pin moves. No data/schema transform is needed.+LIGHTSPEED_RETAIL_SOURCE_TYPE = "LightspeedRetail"+DEPRECATED_VERSION = "2026-01"+TARGET_VERSION = "2026-07"+++def repin_lightspeed_retail_api_version_2026_07(apps, schema_editor):+ ExternalDataSource = apps.get_model("warehouse_sources", "ExternalDataSource")++ # Only touch source-level pins still on the deprecated version. NULL pins already resolve to the+ # source's `default_version` (2026-07), and pins on the separately deprecated 2.0 stay put.+ # Filtering on the exact old value keeps this idempotent: a re-run matches nothing. Schema-level+ # overrides (`ExternalDataSchema.api_version`) are customer-pinned and are left untouched.+ ExternalDataSource.objects.filter(source_type=LIGHTSPEED_RETAIL_SOURCE_TYPE, api_version=DEPRECATED_VERSION).update(+ api_version=TARGET_VERSION+ )+++class Migration(migrations.Migration):+ dependencies = [+ ("warehouse_sources", "0175_repin_llama_cloud_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 2026-07 pins.+ migrations.RunPython(repin_lightspeed_retail_api_version_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.txtindex 95dc51ceef78..94a9f6bc2f0e 100644--- a/products/warehouse_sources/backend/migrations/max_migration.txt+++ b/products/warehouse_sources/backend/migrations/max_migration.txt@@ -1 +1 @@-0175_repin_llama_cloud_api_version+0176_repin_lightspeed_retail_api_version_2026_07diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/lightspeed_retail/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/lightspeed_retail/source.pyindex 33d4a1905692..338d972d61d0 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/lightspeed_retail/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/lightspeed_retail/source.py@@ -1,3 +1,4 @@+from datetime import datefrom typing import Optional, castfrom products.warehouse_sources.backend.facade.source_config import (@@ -52,8 +53,13 @@ class LightspeedRetailSource(ResumableSource[LightspeedRetailSourceConfig, Lightdefault_version = LIGHTSPEED_RETAIL_API_VERSION_2026_07api_docs_url = "https://x-series-api.lightspeedhq.com/docs/introduction"# X-Series deprecated the legacy 2.0 version; no firm sunset date is published (deprecated- # endpoints increasingly return 410 Gone before an eventual retirement).- deprecated_versions = (VersionDeprecation(version=LIGHTSPEED_RETAIL_API_VERSION_2_0, sunset_at=None),)+ # endpoints increasingly return 410 Gone before an eventual retirement). Date-based versions are+ # supported for 12 months (2026-01 until January 2027); past that a request silently falls back+ # to the oldest supported version instead of failing, so the pin would stop being honored.+ deprecated_versions = (+ VersionDeprecation(version=LIGHTSPEED_RETAIL_API_VERSION_2_0, sunset_at=None),+ VersionDeprecation(version=LIGHTSPEED_RETAIL_API_VERSION_2026_01, sunset_at=date(2027, 1, 1)),+ )lists_tables_without_credentials = True # static endpoint catalog — safe for public docsdiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/lightspeed_retail/tests/test_lightspeed_retail_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/lightspeed_retail/tests/test_lightspeed_retail_source.pyindex 1f733affbb8c..1174641c088b 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/lightspeed_retail/tests/test_lightspeed_retail_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/lightspeed_retail/tests/test_lightspeed_retail_source.py@@ -1,3 +1,5 @@+import datetime+import pytestfrom unittest import mock@@ -43,6 +45,20 @@ class TestLightspeedRetailSource:for key in non_retryable_errors)+ @pytest.mark.parametrize(+ "version, expected_sunset",+ [+ (LIGHTSPEED_RETAIL_API_VERSION_2_0, None),+ (LIGHTSPEED_RETAIL_API_VERSION_2026_01, datetime.date(2027, 1, 1)),+ ],+ )+ def test_deprecated_api_version_metadata(self, version, expected_sunset):+ # Drives the in-product warning and the source-level repin migration.+ deprecation = self.source.get_version_deprecation(version)+ assert deprecation is not None+ assert deprecation.sunset_at == expected_sunset+ assert self.source.get_version_deprecation(LIGHTSPEED_RETAIL_API_VERSION_2026_07) is None+@pytest.mark.parametrize("mock_return, expected_valid, expected_message",[