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): support Shopify API version 2026-07 (#71662)

Tom Owers527d71b65a6f
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/constants.py b/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/constants.py
index 5d4cc1b1b3ef..48dd803e49c5 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/constants.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/constants.py
@@ -12,7 +12,11 @@ from .utils import ShopifyGraphQLObject
SHOPIFY_ACCESS_TOKEN_URL = "https://{}.myshopify.com/admin/oauth/access_token"
SHOPIFY_ACCESS_SCOPES_URL = "https://{}.myshopify.com/admin/oauth/access_scopes.json"
SHOPIFY_ACCESS_TOKEN_GRANT = "client_credentials"
-SHOPIFY_API_VERSION = "2025-10"
+# Shopify ships date-based quarterly API versions. One constant per supported version so the
+# source's version declaration (`ShopifySource.supported_versions`) and the request layer (the
+# version segment in the Admin API URL) share a single label — never parsed or ordered.
+SHOPIFY_API_VERSION_2025_10 = "2025-10"
+SHOPIFY_API_VERSION_2026_07 = "2026-07"
SHOPIFY_API_URL = "https://{}.myshopify.com/admin/api/{}/graphql.json"
SHOPIFY_DEFAULT_PAGE_SIZE = 100
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/shopify.py b/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/shopify.py
index 1f2bc581a221..f776918af4ea 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/shopify.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/shopify.py
@@ -26,7 +26,7 @@ from .constants import (
SHOPIFY_ACCESS_TOKEN_GRANT,
SHOPIFY_ACCESS_TOKEN_URL,
SHOPIFY_API_URL,
- SHOPIFY_API_VERSION,
+ SHOPIFY_API_VERSION_2026_07,
SHOPIFY_DEFAULT_PAGE_SIZE,
SHOPIFY_GRAPHQL_OBJECTS,
SHOPIFY_PAGE_SIZE_OVERRIDES,
@@ -384,10 +384,11 @@ def shopify_source(
db_incremental_field_earliest_value: Any | None,
logger: FilteringBoundLogger,
resumable_source_manager: ResumableSourceManager[ShopifyResumeConfig],
+ api_version: str = SHOPIFY_API_VERSION_2026_07,
should_use_incremental_field: bool = False,
):
store_id = normalize_store_id(shopify_store_id)
- api_url = SHOPIFY_API_URL.format(store_id, SHOPIFY_API_VERSION)
+ api_url = SHOPIFY_API_URL.format(store_id, api_version)
shopify_access_token = _get_shopify_access_token(store_id, shopify_client_id, shopify_client_secret)
schema_name = resolve_schema_name(graphql_object_name)
@@ -512,9 +513,16 @@ def _format_graphql_errors(errors: Any) -> str:
return str(errors)
-def _authenticated_session(store_id: str, client_id: str, client_secret: str) -> tuple[str, requests.Session]:
- """Fetch an access token and return the GraphQL URL plus a session that carries it."""
- api_url = SHOPIFY_API_URL.format(store_id, SHOPIFY_API_VERSION)
+def _authenticated_session(
+ store_id: str, client_id: str, client_secret: str, api_version: str = SHOPIFY_API_VERSION_2026_07
+) -> tuple[str, requests.Session]:
+ """Fetch an access token and return the GraphQL URL plus a session that carries it.
+
+ Shopify carries the version in the URL path, so callers that have a source pin must pass it:
+ a 2025-10-pinned source has to validate and probe permissions against 2025-10, not the
+ current default. Pre-creation callers omit it and get `default_version`.
+ """
+ api_url = SHOPIFY_API_URL.format(store_id, api_version)
access_token = _get_shopify_access_token(store_id, client_id, client_secret)
sess = make_tracked_session(headers={"Content-Type": "application/json", "X-Shopify-Access-Token": access_token})
return api_url, sess
@@ -535,7 +543,11 @@ def _probe_resource_permission(api_url: str, sess: requests.Session, resource: S
def validate_credentials(
- shopify_store_id: str, shopify_client_id: str, shopify_client_secret: str, resources: list[str] | None = None
+ shopify_store_id: str,
+ shopify_client_id: str,
+ shopify_client_secret: str,
+ resources: list[str] | None = None,
+ api_version: str = SHOPIFY_API_VERSION_2026_07,
) -> bool:
"""Validate Shopify credentials.
@@ -545,7 +557,7 @@ def validate_credentials(
naming any whose scope is missing.
"""
store_id = normalize_store_id(shopify_store_id)
- api_url, sess = _authenticated_session(store_id, shopify_client_id, shopify_client_secret)
+ api_url, sess = _authenticated_session(store_id, shopify_client_id, shopify_client_secret, api_version)
# A valid token can always read the shop resource.
try:
@@ -574,13 +586,17 @@ def validate_credentials(
def check_endpoint_permissions(
- shopify_store_id: str, shopify_client_id: str, shopify_client_secret: str, endpoints: list[str]
+ shopify_store_id: str,
+ shopify_client_id: str,
+ shopify_client_secret: str,
+ endpoints: list[str],
+ api_version: str = SHOPIFY_API_VERSION_2026_07,
) -> dict[str, str | None]:
"""Per-endpoint read-scope probe for the schema picker: {name: None} if reachable, else a
message naming the missing scope. A throttle/5xx/transport blip on one endpoint leaves that
table unknown rather than aborting the batch; only failing to obtain the access token raises."""
store_id = normalize_store_id(shopify_store_id)
- api_url, sess = _authenticated_session(store_id, shopify_client_id, shopify_client_secret)
+ api_url, sess = _authenticated_session(store_id, shopify_client_id, shopify_client_secret, api_version)
results: dict[str, str | None] = {}
for name in endpoints:
resource = SHOPIFY_GRAPHQL_OBJECTS.get(resolve_schema_name(name))
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/source.py
index 0c1a2324d948..e43c2c3d3d14 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/source.py
@@ -23,7 +23,11 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.sch
from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.shopify import (
ShopifySourceConfig,
)
-from products.warehouse_sources.backend.temporal.data_imports.sources.shopify.constants import SHOPIFY_GRAPHQL_OBJECTS
+from products.warehouse_sources.backend.temporal.data_imports.sources.shopify.constants import (
+ SHOPIFY_API_VERSION_2025_10,
+ SHOPIFY_API_VERSION_2026_07,
+ SHOPIFY_GRAPHQL_OBJECTS,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.shopify.settings import ENDPOINT_CONFIGS
from products.warehouse_sources.backend.temporal.data_imports.sources.shopify.shopify import (
SHOPIFY_ACCESS_TOKEN_AUTH_ERROR,
@@ -43,8 +47,8 @@ from products.warehouse_sources.backend.types import ExternalDataSourceType
@SourceRegistry.register
class ShopifySource(ResumableSource[ShopifySourceConfig, ShopifyResumeConfig]):
- supported_versions = ("2025-10",)
- default_version = "2025-10"
+ supported_versions = (SHOPIFY_API_VERSION_2025_10, SHOPIFY_API_VERSION_2026_07)
+ default_version = SHOPIFY_API_VERSION_2026_07
api_docs_url = "https://shopify.dev/docs/api/release-notes"
lists_tables_without_credentials = True # static endpoint catalog — safe for public docs
@@ -136,7 +140,11 @@ class ShopifySource(ResumableSource[ShopifySourceConfig, ShopifyResumeConfig]):
resources = [schema_name] if schema_name is not None else None
try:
if validate_shopify_credentials(
- config.shopify_store_id, config.shopify_client_id, config.shopify_client_secret, resources
+ config.shopify_store_id,
+ config.shopify_client_id,
+ config.shopify_client_secret,
+ resources,
+ self.resolve_api_version(api_version),
):
return True, None
return False, "Invalid Shopify credentials"
@@ -149,7 +157,11 @@ class ShopifySource(ResumableSource[ShopifySourceConfig, ShopifyResumeConfig]):
self, config: ShopifySourceConfig, team_id: int, endpoints: list[str], api_version: str | None = None
) -> dict[str, str | None]:
return check_shopify_endpoint_permissions(
- config.shopify_store_id, config.shopify_client_id, config.shopify_client_secret, endpoints
+ config.shopify_store_id,
+ config.shopify_client_id,
+ config.shopify_client_secret,
+ endpoints,
+ self.resolve_api_version(api_version),
)
def get_schemas(
@@ -193,6 +205,7 @@ class ShopifySource(ResumableSource[ShopifySourceConfig, ShopifyResumeConfig]):
shopify_client_id=config.shopify_client_id,
shopify_client_secret=config.shopify_client_secret,
graphql_object_name=inputs.schema_name,
+ api_version=self.resolve_api_version(inputs.api_version),
should_use_incremental_field=inputs.should_use_incremental_field,
db_incremental_field_last_value=inputs.db_incremental_field_last_value,
db_incremental_field_earliest_value=inputs.db_incremental_field_earliest_value,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/tests/test_api_version.py b/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/tests/test_api_version.py
new file mode 100644
index 000000000000..2bf319754f25
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/tests/test_api_version.py
@@ -0,0 +1,152 @@
+from typing import Any
+
+import pytest
+from unittest.mock import MagicMock, patch
+
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
+from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.shopify import (
+ ShopifySourceConfig,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.shopify.constants import (
+ ORDERS,
+ SHOPIFY_API_VERSION_2025_10,
+ SHOPIFY_API_VERSION_2026_07,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.shopify.shopify import shopify_source
+from products.warehouse_sources.backend.temporal.data_imports.sources.shopify.source import ShopifySource
+
+
+def _make_inputs(api_version: str | None) -> MagicMock:
+ inputs = MagicMock()
+ inputs.schema_name = ORDERS
+ inputs.api_version = api_version
+ inputs.should_use_incremental_field = False
+ inputs.db_incremental_field_last_value = None
+ inputs.db_incremental_field_earliest_value = None
+ return inputs
+
+
+class TestApiVersionResolution:
+ def test_both_versions_are_supported(self) -> None:
+ # The default flip is covered by the (None -> 2026-07) resolution case below; this only
+ # guards that the legacy version stays declared alongside the new one.
+ assert set(ShopifySource.supported_versions) == {SHOPIFY_API_VERSION_2025_10, SHOPIFY_API_VERSION_2026_07}
+
+ @pytest.mark.parametrize(
+ "pin, expected",
+ [
+ (SHOPIFY_API_VERSION_2025_10, SHOPIFY_API_VERSION_2025_10),
+ (SHOPIFY_API_VERSION_2026_07, SHOPIFY_API_VERSION_2026_07),
+ # An unpinned source resolves to the current default rather than the legacy version.
+ (None, SHOPIFY_API_VERSION_2026_07),
+ ],
+ )
+ @patch("products.warehouse_sources.backend.temporal.data_imports.sources.shopify.source.shopify_source")
+ def test_resolved_pin_reaches_request_layer(
+ self, mock_shopify_source: MagicMock, pin: str | None, expected: str
+ ) -> None:
+ source = ShopifySource()
+ config = ShopifySourceConfig(
+ shopify_store_id="my-store", shopify_client_id="client-id", shopify_client_secret="secret"
+ )
+
+ source.source_for_pipeline(config, MagicMock(spec=ResumableSourceManager), _make_inputs(pin))
+
+ assert mock_shopify_source.call_args.kwargs["api_version"] == expected
+
+
+class TestApiVersionReachesRequestUrl:
+ @pytest.mark.parametrize("api_version", [SHOPIFY_API_VERSION_2025_10, SHOPIFY_API_VERSION_2026_07])
+ @patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.shopify.shopify._get_shopify_access_token",
+ return_value="test-token",
+ )
+ @patch("products.warehouse_sources.backend.temporal.data_imports.sources.shopify.shopify.requests.Session")
+ def test_version_is_the_url_segment(self, session_cls: MagicMock, _mock_token: MagicMock, api_version: str) -> None:
+ posted_urls: list[str] = []
+
+ def _post(url: str, json: dict[str, Any] | None = None, **kwargs: Any) -> MagicMock:
+ posted_urls.append(url)
+ response = MagicMock()
+ response.status_code = 200
+ response.ok = True
+ response.json.return_value = {
+ "data": {ORDERS: {"nodes": [], "pageInfo": {"hasNextPage": False, "endCursor": None}}}
+ }
+ return response
+
+ session_cls.return_value.post.side_effect = _post
+
+ source = shopify_source(
+ shopify_store_id="my-store",
+ shopify_client_id="id",
+ shopify_client_secret="secret",
+ graphql_object_name=ORDERS,
+ db_incremental_field_last_value=None,
+ db_incremental_field_earliest_value=None,
+ logger=MagicMock(),
+ resumable_source_manager=MagicMock(),
+ api_version=api_version,
+ )
+ list(source.items())
+
+ assert posted_urls == [f"https://my-store.myshopify.com/admin/api/{api_version}/graphql.json"]
+
+
+class TestNonSyncSurfacesUseResolvedPin:
+ """Credential validation and permission probes carry the version in the URL too, so a pinned
+ source must probe under its own pin — not the current default."""
+
+ @pytest.mark.parametrize(
+ "pin, expected",
+ [
+ (SHOPIFY_API_VERSION_2025_10, SHOPIFY_API_VERSION_2025_10),
+ (SHOPIFY_API_VERSION_2026_07, SHOPIFY_API_VERSION_2026_07),
+ (None, SHOPIFY_API_VERSION_2026_07),
+ ],
+ )
+ @patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.shopify.source.validate_shopify_credentials"
+ )
+ def test_validate_credentials_passes_resolved_pin(self, mock_validate: Any, pin: str | None, expected: str) -> None:
+ mock_validate.return_value = True
+ config = ShopifySourceConfig(
+ shopify_store_id="my-store", shopify_client_id="id", shopify_client_secret="secret"
+ )
+
+ ShopifySource().validate_credentials(config, team_id=1, api_version=pin)
+
+ assert mock_validate.call_args.args[-1] == expected
+
+ @pytest.mark.parametrize(
+ "pin, expected",
+ [
+ (SHOPIFY_API_VERSION_2025_10, SHOPIFY_API_VERSION_2025_10),
+ (None, SHOPIFY_API_VERSION_2026_07),
+ ],
+ )
+ @patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.shopify.source.check_shopify_endpoint_permissions"
+ )
+ def test_endpoint_permissions_pass_resolved_pin(self, mock_check: Any, pin: str | None, expected: str) -> None:
+ mock_check.return_value = {}
+ config = ShopifySourceConfig(
+ shopify_store_id="my-store", shopify_client_id="id", shopify_client_secret="secret"
+ )
+
+ ShopifySource().get_endpoint_permissions(config, team_id=1, endpoints=[ORDERS], api_version=pin)
+
+ assert mock_check.call_args.args[-1] == expected
+
+ @pytest.mark.parametrize("api_version", [SHOPIFY_API_VERSION_2025_10, SHOPIFY_API_VERSION_2026_07])
+ @patch("products.warehouse_sources.backend.temporal.data_imports.sources.shopify.shopify._get_shopify_access_token")
+ @patch("products.warehouse_sources.backend.temporal.data_imports.sources.shopify.shopify.make_tracked_session")
+ def test_authenticated_session_url_carries_version(self, session_cls: Any, token: Any, api_version: str) -> None:
+ from products.warehouse_sources.backend.temporal.data_imports.sources.shopify.shopify import (
+ _authenticated_session,
+ )
+
+ token.return_value = "tok"
+ api_url, _ = _authenticated_session("my-store", "id", "secret", api_version)
+
+ assert api_url == f"https://my-store.myshopify.com/admin/api/{api_version}/graphql.json"