: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
chore(warehouse_sources): skip version adds with no vendor divergence (#72964)
Daniel RCc3ae9fb38464
diff --git a/.agents/skills/warehouse-source-new-version/SKILL.md b/.agents/skills/warehouse-source-new-version/SKILL.mdindex 9754d6df171c..8661222e13b5 100644--- a/.agents/skills/warehouse-source-new-version/SKILL.md+++ b/.agents/skills/warehouse-source-new-version/SKILL.md@@ -1,6 +1,6 @@---name: warehouse-source-new-version-description: Add support for a new vendor API version to an existing Data warehouse import source, or deprecate an old one. Use when a vendor ships a new API version (Stripe date versions, Shopify quarterly versions, header-pinned revisions, /vN/ URL bumps), when implementing a version-update or deprecation task for a source under products/warehouse_sources/backend/temporal/data_imports/sources, or when repinning an ExternalDataSource to a different version. Covers version declaration, dispatch, pinning semantics, deprecation metadata, and migration scripts.+description: Add support for a new vendor API version to an existing Data warehouse import source, or deprecate an old one. Use when a vendor ships a new API version (Stripe date versions, Shopify quarterly versions, header-pinned revisions, /vN/ URL bumps), when implementing a version-update or deprecation task for a source under products/warehouse_sources/backend/temporal/data_imports/sources, or when repinning an ExternalDataSource to a different version. Covers deciding whether a newly announced version needs supporting at all, version declaration, dispatch, pinning semantics, deprecation metadata, and migration scripts.---# Adding a new vendor API version to a warehouse source@@ -21,15 +21,37 @@ Use this skill when a vendor has released a new API version and an existing sour- These declarations are exposed publicly via `GET /api/public_source_configs/` (`versions`, `defaultVersion`, `apiDocsUrl`, `deprecatedVersions`) and per-instance via the source API (`api_version`, `api_version_deprecation`). The `api_version` pin is queryable in HogQL via the `data_warehouse_sources` system table.- Registry-wide invariants are enforced by `sources/tests/test_source_versions.py`: default in supported, deprecated ⊆ supported, default never deprecated, https `api_docs_url`.+## First: does the version need to exist at all?++Spotting a new vendor label is not a reason to support it. Before touching any source file, diff the new version against the one it supersedes — the source's current `default_version`, not every entry in `supported_versions` — from the vendor's docs and changelog, area by area:++- authentication — credential fields, token/header scheme, scopes, permission probes+- base URL, version header, and the paths actually served per resource+- pagination — mechanism, params, cursor semantics, page limits+- the schema list — which endpoints/tables the source exposes+- schema formats — columns, types/formats, primary keys, incremental fields+- webhook payloads and subscription registration, for a `WebhookSource`+- rate limits, error signatures, and anything else the source's request layer touches++**If none of that differs for what this source reads, don't add the version.** Leave `supported_versions` and `default_version` untouched and close the task with the per-area, changelog-cited evidence that the new label is indistinguishable from the default here. An extra label buys nothing and costs: a pin users can select, a version the tests, API, and UI carry forever, and the implied claim that the framework dispatches on it.++Add it when any of these hold:++- **any** area above diverges from that baseline, however cosmetic it looks for our reads — then branch it (step 3). Divergence from an older still-supported label doesn't count: those pins keep serving their own request path either way (step 4), so a new label that matches the default is redundant no matter how far it sits from the legacy one;+- the vendor is retiring a version rows are still pinned to, so that label stops working — adopting the new one is the point even if the wire is identical, and the retired version moves to `deprecated_versions` in the same PR;+- the source must send the label to get the behavior it already wants (a required header or URL segment), i.e. the version is a request input, not just a name.++"Nothing changed" needs the same docs evidence as a divergence. An unread changelog is not a clean diff.+## Adding a new version, step by step-1. **Read the vendor's changelog** (the source's `api_docs_url`) and list what changed between the currently supported version(s) and the new one: renamed/removed fields, changed pagination, new required headers, changed webhook payloads. Verification is docs-only — there are no stored credentials and no live-sync harness, so the docs are the sole source of truth for what each version serves.-2. **Declare the version**: add the new label to `supported_versions` and flip `default_version` to it — new sources always start on the newest stable version. A pinned row's **sync** path is unaffected by a default flip (that is the point of pinning), but two things still follow the new default: discovery/`get_schemas` if the pin isn't threaded there (step 3), and any row whose `api_version` is NULL. Reference the request layer's version constants instead of duplicating string literals.+1. **Read the vendor's changelog** (the source's `api_docs_url`) and list what changed between the currently supported version(s) and the new one: renamed/removed fields, changed pagination, new required headers, changed webhook payloads. Verification is docs-only — there are no stored credentials and no live-sync harness, so the docs are the sole source of truth for what each version serves. This is also the evidence the gate above runs on.+2. **Declare the version** (only once the gate says the version has to exist): add the new label to `supported_versions` and flip `default_version` to it — new sources always start on the newest stable version. A pinned row's **sync** path is unaffected by a default flip (that is the point of pinning), but two things still follow the new default: discovery/`get_schemas` if the pin isn't threaded there (step 3), and any row whose `api_version` is NULL. Reference the request layer's version constants instead of duplicating string literals.3. **Dispatch on `SourceInputs.api_version`** at the request layer:- Keep it minimal. If the version is just a header/URL segment and response shapes are compatible, thread the version string down to where the client/URL is built (see Stripe: `StripeSource.source_for_pipeline` passes `self.resolve_api_version(inputs.api_version)` → `stripe_source(...)` → `StripeClient(stripe_version=...)`). Resolve through `resolve_api_version` at the source class — never hardcode a fallback version in the request layer.- Only introduce per-version modules/branches where behavior genuinely diverges (different pagination, different field mapping). Keep all version branching inside the source's own directory — never in shared layers.- When the new version renames endpoints, changes primary keys, or reshapes responses, the divergence must actually be branched — never leave the old single-version request path serving the new default. All the relevant surfaces can vary by version: `get_rows` receives the resolved pin in `inputs.api_version`; credential fields can key off `default_version`.- - Conversely, don't add inert scaffolding: if the vendor doesn't version via a header/URL segment, declaring `supported_versions`/`default_version` is the whole change — an `api_version` param no caller varies, or a version→URL map with identical values, is a review finding, not forward-compat.+ - Conversely, don't add inert scaffolding: an `api_version` param no caller varies, or a version→URL map with identical values, is a review finding, not forward-compat. Declaration-only (`supported_versions`/`default_version` and nothing else) is the correct shape just when the gate above passed on a non-wire reason — the old label is being retired, or the vendor switches behavior account-side rather than per request. If the gate passed on nothing at all, there is no PR.- **Discovery and probe paths receive the pin — consume it.** The framework passes the resolved pin as the `api_version` parameter of `get_schemas`, `validate_credentials`, `get_endpoint_permissions`, and the webhook management methods. A multi-version source MUST build its discovery/probe/webhook clients from that parameter, not from `default_version` or a hardcoded header — otherwise a pinned source discovers/reconciles under the wrong version and its tables can disappear, duplicate, or fail reconciliation. Resolve it with `self.resolve_api_version(api_version)` — callers with a row pass an already-resolved value (mirroring `SourceInputs.api_version`), so the source-side resolve only covers pre-creation calls that pass `None`. Ignoring the parameter is only correct when you can state why the version makes no difference to that path.- Watch for version-dependent column hints/schemas: e.g. Stripe's `external_table_definitions` were built for specific versions. When adding a version whose response shapes differ, gate the canonical column hints to the versions they were built for and let newer versions auto-infer the schema from the data (a set of hint-compatible versions checked where hints are applied). For `has_managed_hogql_schema=True` sources this includes the read path: `hogql_definition`'s canonical column mapping is version-blind, so renamed columns need the canonical schema/descriptions updated too.4. **Keep old versions working**: do not delete or alter the request path for previously supported versions. Removing a version is an explicit future decision, not part of a version-add PR.@@ -71,7 +93,9 @@ After you finish a version-update or deprecation PR using this skill, **append w- (seed) Stripe: response shapes differ enough across date versions that canonical column hints must be gated per version; newer versions auto-infer schema instead.- A new version label doesn't imply new paths: vendors ship a "v2" that still serves resources at `/v1/`, or replace the resource API entirely — check the docs per resource before building `/{version}/{resource}` URLs. A tell-tale in your own diff: needing a different probe/validation endpoint for the new version proves the resource sets diverge, so the sync paths need branching too.- Grep every place the source builds a client or URL (sync, discovery, probes, error matchers, webhooks) when bumping — the ones outside the sync path silently stay on default/legacy versions.-- Simplecast: current API (api.simplecast.com + Bearer) _is_ "2.0" and the `UNVERSIONED_API_VERSION` ("v1") pin already hit it, so both labels resolve to the same live API — adding "2.0" as the new default is a pure declaration change with no wire divergence. Header-based version selection is announced but unshipped, so don't thread a speculative version header onto requests: declare `supported_versions`/`default_version` now and defer the wire dispatch until the real header contract exists (a no-op header ships risk with no present benefit).+- Simplecast: current API (api.simplecast.com + Bearer) _is_ "2.0" and the `UNVERSIONED_API_VERSION` ("v1") pin already hit it, so both labels resolve to the same live API and "2.0" shipped as a pure declaration change. That is exactly the shape the gate now skips — a renamed label over an unchanged API is not a version to support. Header-based version selection is announced but unshipped there, so if it ever ships, don't thread a speculative header ahead of the real contract (a no-op header ships risk with no present benefit).+- Two questions that resolve most "is this a real version?" calls fast: does the source send anything different on the wire, and does anything it reads come back different? Two nos and the only remaining reason to adopt the label is the old one being retired.+- Vendors rename versions for marketing (rebrands, docs-site restructures, "v2 developer platform" launches) far more often than they change the endpoints an ingest-only source reads. Diff resource by resource, not by announcement headline.- Notion 2026-03-11: for read-only syncs a new version is often header-only — its breaking changes (`archived`->`in_trash`, `transcription`->`meeting_notes` block type, `after`->`position` on _append_ block children) only touch response fields or write paths we never call, so with an auto-inferred schema the sole dispatch is threading the resolved version into the request header. No per-version module needed.- When the request layer hardcodes the version as a module constant (e.g. `NOTION_VERSION`), the dispatch is: add a param through the client/session builders (`notion_source` -> `get_rows` -> `_build_session` -> `_get_headers`), pass `self.resolve_api_version(inputs.api_version)` from `source_for_pipeline`, and give the standalone `validate_credentials(token, api_version)` `self.default_version` (creation-time, version-agnostic probe).- Test pattern that stayed cheap: parameterize the header builder over supported versions (header carries requested version) + mock `notion_source` in the source module and assert `call_args.kwargs["api_version"]` for none/legacy/new pins (resolution + threading in one).