: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
fix(active-campaign): accept an api url entered without a scheme (#114356)
Tom Owersda4cb0408e6c
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/active_campaign/active_campaign.py b/products/warehouse_sources/backend/temporal/data_imports/sources/active_campaign/active_campaign.pyindex b9032259ecf5..9b5aedba5c41 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/active_campaign/active_campaign.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/active_campaign/active_campaign.py@@ -33,9 +33,11 @@ def _normalize_base_url(api_url: str) -> str:Users copy the URL straight from their ActiveCampaign developer settings, whichis the bare account host (e.g. https://youraccount.api-us1.com). We tolerate atrailing slash or an accidentally-pasted `/api/3` and re-append the version path- ourselves so the configured base is always consistent.+ ourselves so the configured base is always consistent. A bare host gets `https://`."""url = api_url.strip().rstrip("/")+ if url and "://" not in url:+ url = f"https://{url}"if url.endswith("/api/3"):url = url[: -len("/api/3")]return url@@ -161,7 +163,11 @@ def active_campaign_source(def validate_credentials(api_url: str, api_key: str) -> tuple[bool, str | None]:base_url = _normalize_base_url(api_url)if not base_url.startswith("https://"):- return False, "ActiveCampaign API URL must start with https://"+ return (+ False,+ "Your ActiveCampaign API URL must start with https://. Copy it from Settings > Developer in "+ "ActiveCampaign, then try again.",+ )# Defense-in-depth SSRF check (the Smokescreen egress proxy is the load-bearing# control): reject localhost, cloud-metadata hosts, internal domains, and privatediff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/active_campaign/tests/test_active_campaign.py b/products/warehouse_sources/backend/temporal/data_imports/sources/active_campaign/tests/test_active_campaign.pyindex abd63fc97882..d19de365a6fc 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/active_campaign/tests/test_active_campaign.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/active_campaign/tests/test_active_campaign.py@@ -40,6 +40,9 @@ class TestNormalizeBaseUrl:("https://acme.api-us1.com/api/3", "https://acme.api-us1.com"),("https://acme.api-us1.com/api/3/", "https://acme.api-us1.com"),(" https://acme.api-us1.com ", "https://acme.api-us1.com"),+ ("acme.api-us1.com", "https://acme.api-us1.com"),+ ("acme.api-us1.com/api/3/", "https://acme.api-us1.com"),+ ("http://acme.api-us1.com", "http://acme.api-us1.com"),],)def test_normalize(self, raw: str, expected: str) -> None: