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.

fix(data-warehouse): stop echoing the typed value in the shopify store id error (#126030)

Tom Owers672394307d7f
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 05bc37d373c8..ca7aae54a81d 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
@@ -595,6 +595,11 @@ def _read_in_parallel(
# A Shopify store subdomain is lowercase alphanumerics and hyphens.
_SHOPIFY_SUBDOMAIN_RE = re.compile(r"^[a-z0-9][a-z0-9-]*$")
+# People often paste their store's custom domain here, so the message names that case.
+SHOPIFY_INVALID_STORE_ID_ERROR = (
+ "Your store id must be the subdomain of your myshopify.com address. Enter the 'my-store' "
+ "in 'my-store.myshopify.com', not your store's own domain."
+)
def normalize_store_id(raw: str) -> str:
@@ -624,10 +629,7 @@ def normalize_store_id(raw: str) -> str:
while store_id.endswith(".myshopify.com"):
store_id = store_id.removesuffix(".myshopify.com")
if not _SHOPIFY_SUBDOMAIN_RE.match(store_id):
- raise ValueError(
- f"Invalid Shopify store id {raw!r}. Enter just your store subdomain — the 'my-store' "
- "in 'my-store.myshopify.com'."
- )
+ raise ValueError(SHOPIFY_INVALID_STORE_ID_ERROR)
return store_id
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/tests/test_store_id.py b/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/tests/test_store_id.py
index d0bff2bd73d7..028642dd04b8 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/tests/test_store_id.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/tests/test_store_id.py
@@ -5,6 +5,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.tes
scripted_network,
)
from products.warehouse_sources.backend.temporal.data_imports.sources.shopify.shopify import (
+ SHOPIFY_INVALID_STORE_ID_ERROR,
_get_shopify_access_token,
normalize_store_id,
)
@@ -40,14 +41,16 @@ def test_normalize_store_id_accepts_common_paste_forms(raw, expected):
"",
" ",
"https://evil.com",
+ "shop.example.com",
"my_store",
"store with spaces",
"-leading-hyphen",
],
)
def test_normalize_store_id_rejects_invalid(raw):
- with pytest.raises(ValueError):
+ with pytest.raises(ValueError) as exc_info:
normalize_store_id(raw)
+ assert str(exc_info.value) == SHOPIFY_INVALID_STORE_ID_ERROR
def test_access_token_url_has_no_doubled_suffix_for_messy_input():