: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 fleetio api version v1 (#126926)
Tom Owers9b943104e07a
diff --git a/.agents/skills/warehouse-source-new-version/SKILL.md b/.agents/skills/warehouse-source-new-version/SKILL.mdindex ef7a36b7f60c..ddbc9ea51ea6 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 OpenAP2. 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, 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.+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. A support floor ("supported for at least N years, after which a version may be scheduled for deprecation") is not: nothing ends at N years until the vendor schedules it, so stay advisory. 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/temporal/data_imports/sources/fleetio/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/fleetio/source.pyindex 9fd70b69b045..a2e3fc1bab18 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/fleetio/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/fleetio/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,)@@ -21,6 +25,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.schfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceInputs, SourceResponsefrom products.warehouse_sources.backend.temporal.data_imports.sources.fleetio.fleetio import (DEFAULT_VERSION,+ FLEETIO_LEGACY_VERSION,SUPPORTED_VERSIONS,FleetioResumeConfig,fleetio_source,@@ -42,6 +47,9 @@ class FleetioSource(ResumableSource[FleetioSourceConfig, FleetioResumeConfig]):supported_versions = SUPPORTED_VERSIONSdefault_version = DEFAULT_VERSION+ # Fleetio deprecated path-segment endpoint versions (`/api/v1`, `/api/v2`), which the "v1" pin+ # still reads, but still serves them and has announced no sunset date.+ deprecated_versions = (VersionDeprecation(version=FLEETIO_LEGACY_VERSION, sunset_at=None),)api_docs_url = "https://developer.fleetio.com/docs/overview/versioning"lists_tables_without_credentials = True # static endpoint catalog — safe for public docsdiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/fleetio/tests/test_fleetio_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/fleetio/tests/test_fleetio_source.pyindex 281cd4af3906..eda5da0eb804 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/fleetio/tests/test_fleetio_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/fleetio/tests/test_fleetio_source.py@@ -28,6 +28,7 @@ class TestFleetioSource:# rows keep syncing unchanged.assert self.source.default_version == "2025-05-05"assert set(self.source.supported_versions) == {"v1", "2025-05-05"}+ assert [(d.version, d.sunset_at) for d in self.source.deprecated_versions] == [("v1", None)]@pytest.mark.parametrize("probe_result,expected_valid", [(True, True), (False, False)])def test_validate_credentials(self, probe_result: bool, expected_valid: bool, monkeypatch: Any) -> None: