: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): support loop returns API version 2026-10 (#126933)
Tom Owers93f73d6d8970
diff --git a/products/warehouse_sources/backend/migrations/0192_repin_loop_returns_api_version.py b/products/warehouse_sources/backend/migrations/0192_repin_loop_returns_api_version.pynew file mode 100644index 000000000000..0be5102b0cf3--- /dev/null+++ b/products/warehouse_sources/backend/migrations/0192_repin_loop_returns_api_version.py@@ -0,0 +1,41 @@+from django.db import migrations++# Loop removes the `v1` alias when the `2026-07` version it points at sunsets on 2028-07-15. After the+# sunset Loop does not reject the request: it serves the oldest supported version, so a `v1` pin silently+# stops selecting the version it names. This repins source-level `v1` pins to "2026-10" (the current+# default).+#+# No data or schema transform accompanies the repin. Both versions call the same list paths with the same+# pagination and response shapes; only the version segment in the URL differs. The 2026-10 breaking changes+# touch write endpoints, draft returns and a 120-day range check on the ASN report, which this source+# already stays under with 90-day windows.+SOURCE_TYPE = "LoopReturns"+DEPRECATED_VERSION = "v1"+NEW_VERSION = "2026-10"+++def repin_loop_returns_v1_to_2026_10(apps, schema_editor):+ ExternalDataSource = apps.get_model("warehouse_sources", "ExternalDataSource")++ # Source-level pin only. 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` ("2026-10"), and "2026-07" pins are still+ # served, so neither is touched. Matching only `api_version="v1"` keeps this idempotent: a second run+ # matches nothing.+ ExternalDataSource.objects.filter(source_type=SOURCE_TYPE, api_version=DEPRECATED_VERSION).update(+ api_version=NEW_VERSION+ )+++class Migration(migrations.Migration):+ dependencies = [+ ("warehouse_sources", "0191_repin_qualys_vmdr_api_version_6_0"),+ ]++ operations = [+ # Reverse is a no-op: once repinned, "2026-10" rows are indistinguishable from natively-created ones,+ # so a blanket downgrade would clobber legitimate "2026-10" pins.+ migrations.RunPython(repin_loop_returns_v1_to_2026_10, 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 8be49032f927..3d559ac5e2b2 100644--- a/products/warehouse_sources/backend/migrations/max_migration.txt+++ b/products/warehouse_sources/backend/migrations/max_migration.txt@@ -1 +1 @@-0191_repin_qualys_vmdr_api_version_6_0+0192_repin_loop_returns_api_versiondiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/loop_returns/loop_returns.py b/products/warehouse_sources/backend/temporal/data_imports/sources/loop_returns/loop_returns.pyindex 2a0595f2f467..cb50fcd07e91 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/loop_returns/loop_returns.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/loop_returns/loop_returns.py@@ -40,11 +40,12 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.loop_returlogger = logging.getLogger(__name__)-# Loop versions its API by date in the URL path (`/api/2026-07/...`). `v1` is a legacy-# convenience alias for the `2026-07` GA release, kept for backward compatibility and being-# phased out; new integrations pin the explicit date version.+# Loop versions its API by date in the URL path (`/api/2026-10/...`). `v1` is a legacy+# convenience alias for the `2026-07` GA release, kept for backward compatibility and removed when+# `2026-07` sunsets; new integrations pin an explicit date version.API_VERSION_V1 = "v1"API_VERSION_2026_07 = "2026-07"+API_VERSION_2026_10 = "2026-10"API_HOST = "https://api.loopreturns.com"AUTH_HEADER = "X-Authorization"diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/loop_returns/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/loop_returns/source.pyindex 3030e94156f7..7af06f3fd0ec 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/loop_returns/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/loop_returns/source.py@@ -1,3 +1,4 @@+from datetime import datefrom typing import Optional, castfrom products.warehouse_sources.backend.facade.codebase_detection import detect@@ -28,6 +29,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.generated_)from products.warehouse_sources.backend.temporal.data_imports.sources.loop_returns.loop_returns import (API_VERSION_2026_07,+ API_VERSION_2026_10,API_VERSION_V1,LoopReturnsResumeConfig,endpoint_permissions,@@ -48,12 +50,13 @@ class LoopReturnsSource(ResumableSource[LoopReturnsSourceConfig, LoopReturnsResulists_tables_without_credentials = True # static endpoint catalog — safe for public docs- # Loop versions its API by date in the URL path (`/api/2026-07/...`). `v1` is a legacy alias- # for the `2026-07` GA release that Loop is phasing out, so new sources pin the explicit date- # version and `v1` is marked deprecated. No calendar sunset date is published for the alias.- supported_versions = (API_VERSION_V1, API_VERSION_2026_07)- default_version = API_VERSION_2026_07- deprecated_versions = (VersionDeprecation(version=API_VERSION_V1, sunset_at=None),)+ # Loop versions its API by date in the URL path (`/api/2026-10/...`). `v1` is a legacy alias+ # for the `2026-07` release and Loop removes it when `2026-07` sunsets on 2028-07-15. After the+ # sunset Loop serves the oldest supported version instead of rejecting the request, so there is+ # no rejection error to map.+ supported_versions = (API_VERSION_V1, API_VERSION_2026_07, API_VERSION_2026_10)+ default_version = API_VERSION_2026_10+ deprecated_versions = (VersionDeprecation(version=API_VERSION_V1, sunset_at=date(2028, 7, 15)),)api_docs_url = "https://docs.loopreturns.com/api-reference/versioning"@propertydiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/loop_returns/tests/test_loop_returns_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/loop_returns/tests/test_loop_returns_source.pyindex 9c9448b57d11..9aef04a77924 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/loop_returns/tests/test_loop_returns_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/loop_returns/tests/test_loop_returns_source.py@@ -35,12 +35,14 @@ class TestLoopReturnsSource:with scripted_network([ScriptedResponse(status=200)]):assert self.source.validate_credentials(config, self.team_id) == (True, None)- def test_source_for_pipeline_builds_the_requested_table(self) -> None:+ @pytest.mark.parametrize("api_version", LoopReturnsSource.supported_versions)+ def test_source_for_pipeline_builds_the_requested_table_on_the_pinned_version(self, api_version: str) -> None:result = SourceDriver(self.source, self.config).run(- "advanced_shipping_notices", always(ScriptedResponse(json=[]))+ "advanced_shipping_notices", always(ScriptedResponse(json=[])), api_version=api_version)assert result.raised is Noneassert result.response is not Noneassert result.response.name == "advanced_shipping_notices"assert result.response.primary_keys == ["id", "return_line_item_id"]+ assert result.paths and all(path == f"/api/{api_version}/warehouse/reporting/asn" for path in result.paths)