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(pipedrive): clearer error when company domain is a full URL (#69589)

Tom Owers1be2446c02e0
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/pipedrive/pipedrive.py b/products/warehouse_sources/backend/temporal/data_imports/sources/pipedrive/pipedrive.py
index 4658b9be602d..30e190f8e04d 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/pipedrive/pipedrive.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/pipedrive/pipedrive.py
@@ -23,6 +23,14 @@ MAX_RETRIES = 5
_SUBDOMAIN_RE = re.compile(r"^[a-z0-9-]+$")
+# Never reflects the raw input back: it can be a full URL or website domain the user pasted by
+# mistake, and echoing it gives no guidance on what a valid value looks like.
+_INVALID_COMPANY_DOMAIN_ERROR = (
+ "Invalid Pipedrive company domain. Enter just your Pipedrive subdomain — the part before "
+ ".pipedrive.com (for example, enter 'acme' for acme.pipedrive.com) — not a full URL or your "
+ "website's domain."
+)
+
class PipedriveRetryableError(Exception):
pass
@@ -47,7 +55,7 @@ def normalize_company_domain(raw: str) -> str:
domain = domain.split("/")[0]
domain = domain.removesuffix(".pipedrive.com")
if not _SUBDOMAIN_RE.match(domain):
- raise ValueError(f"Invalid Pipedrive company domain: {raw!r}")
+ raise ValueError(_INVALID_COMPANY_DOMAIN_ERROR)
return domain
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/pipedrive/tests/test_pipedrive.py b/products/warehouse_sources/backend/temporal/data_imports/sources/pipedrive/tests/test_pipedrive.py
index 7c3e8f29e308..80066b438902 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/pipedrive/tests/test_pipedrive.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/pipedrive/tests/test_pipedrive.py
@@ -48,6 +48,13 @@ class TestNormalizeCompanyDomain:
with pytest.raises(ValueError):
normalize_company_domain(raw)
+ def test_rejection_message_guides_without_echoing_input(self) -> None:
+ with pytest.raises(ValueError) as exc_info:
+ normalize_company_domain("https://secret-subdomain.example.com/")
+ message = str(exc_info.value)
+ assert "secret-subdomain" not in message
+ assert "pipedrive.com" in message
+
def test_base_url_is_pinned_to_pipedrive(self) -> None:
assert base_url("mycompany") == "https://mycompany.pipedrive.com"
assert base_url("https://MyCompany.pipedrive.com") == "https://mycompany.pipedrive.com"