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(adobe-commerce): explain an invalid store code without echoing it (#114357)

Tom Owerscb3c4984817a
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/adobe_commerce/adobe_commerce.py b/products/warehouse_sources/backend/temporal/data_imports/sources/adobe_commerce/adobe_commerce.py
index c3b0fab742dd..10c0cf61f9ff 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/adobe_commerce/adobe_commerce.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/adobe_commerce/adobe_commerce.py
@@ -72,6 +72,10 @@ HOST_NOT_ALLOWED_ERROR = "Adobe Commerce store URL is not allowed"
INCOMPLETE_CREDENTIALS_ERROR = "Adobe Commerce credentials are incomplete"
HTTPS_REQUIRED_ERROR = "Adobe Commerce store URL must use HTTPS"
PAGINATION_LIMIT_ERROR = "Adobe Commerce pagination did not terminate"
+INVALID_STORE_CODE_ERROR = (
+ "Your store code isn't valid. Use the store view code from Stores > Settings > All Stores in your "
+ "Adobe Commerce admin, not its numeric ID, or leave the field blank."
+)
# Reached only after the tracked session's own transport-level retries for 429/5xx are exhausted
# (see `_mint`), so this is self-recovering — matched by `AdobeCommerceSource.get_retryable_errors`
# to keep it out of error tracking. The status code is left out of the constant since it varies.
@@ -189,7 +193,7 @@ def normalize_store_code(store_code: str | None) -> str:
if not cleaned:
return ""
if not _STORE_CODE_RE.match(cleaned):
- raise ValueError(f"Invalid Adobe Commerce store code: {store_code!r}")
+ raise ValueError(INVALID_STORE_CODE_ERROR)
return cleaned
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/adobe_commerce/tests/test_adobe_commerce.py b/products/warehouse_sources/backend/temporal/data_imports/sources/adobe_commerce/tests/test_adobe_commerce.py
index 2de3e1e1617b..c0e87dd12985 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/adobe_commerce/tests/test_adobe_commerce.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/adobe_commerce/tests/test_adobe_commerce.py
@@ -172,9 +172,16 @@ class TestStoreCodeAndBaseUrl:
def test_normalize_store_code(self, _name: str, raw: str | None, expected: str) -> None:
assert normalize_store_code(raw) == expected
- @parameterized.expand([("path_segment", "de/../all"), ("leading_digit", "1store"), ("dotted", "de.store")])
+ @parameterized.expand(
+ [
+ ("path_segment", "de/../all"),
+ ("leading_digit", "1store"),
+ ("dotted", "de.store"),
+ ("numeric_store_id", "1"),
+ ]
+ )
def test_normalize_store_code_rejects_path_injection(self, _name: str, raw: str) -> None:
- with pytest.raises(ValueError):
+ with pytest.raises(ValueError, match="store view code"):
normalize_store_code(raw)
@parameterized.expand(