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(convex): explain custom-domain and unknown-deployment url errors (#115254)

Tom Owersbb0f2ad4299e
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/convex/convex.py b/products/warehouse_sources/backend/temporal/data_imports/sources/convex/convex.py
index f4b0d57d5644..b85a8c18eeed 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/convex/convex.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/convex/convex.py
@@ -80,9 +80,11 @@ def validate_deploy_url(deploy_url: str) -> str:
host = (parsed.hostname or "").lower()
if not host or not _CONVEX_CLOUD_HOST_RE.match(host):
+ # The deploy key only goes to Convex-hosted deployments, so custom domains and
+ # self-hosted backends are refused here rather than probed.
raise InvalidDeployUrlError(
- f"Deployment URL host must match <deployment-name>.convex.cloud or "
- f"<deployment-name>.<region>.convex.cloud, got: {host!r}."
+ "Enter your deployment's .convex.cloud URL, not a custom domain. "
+ "Copy it from Settings > URL & Deploy Key in your Convex dashboard, then reconnect."
)
if parsed.query:
@@ -442,12 +444,16 @@ def validate_credentials(deploy_url: str, deploy_key: str) -> tuple[bool, str |
False,
"Convex rejected your deploy key. Copy a new deploy key from your Convex dashboard, then reconnect.",
)
+ if e.response.status_code == 404:
+ return (
+ False,
+ "PostHog couldn't find this Convex deployment. Copy the deployment URL from your Convex dashboard, then reconnect.",
+ )
# Any other status falls through to a generic message. Keep the raw error
# (which embeds the deployment URL) out of what the user sees.
- detail = f" (HTTP {e.response.status_code})" if e.response is not None else ""
return (
False,
- f"The Convex deployment rejected the request{detail}. Check your deployment URL and deploy key, then try again.",
+ "The Convex deployment rejected the request. Check your deployment URL and deploy key, then try again.",
)
except RequestsConnectionError:
return False, "Could not connect to the Convex deployment. Check your deployment URL and try again."
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/convex/tests/test_convex.py b/products/warehouse_sources/backend/temporal/data_imports/sources/convex/tests/test_convex.py
index 65d2437e93aa..00563109c319 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/convex/tests/test_convex.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/convex/tests/test_convex.py
@@ -1,5 +1,6 @@
from collections.abc import Iterable, Iterator
from typing import Any, cast
+from urllib.parse import urlparse
import pytest
from unittest.mock import Mock, patch
@@ -101,6 +102,7 @@ class TestValidateDeployUrl:
@parameterized.expand(
[
("bad_url", "http://169.254.169.254", "deploy-key"),
+ ("custom_domain", "https://convex.example.com", "deploy-key"),
("unsendable_key", "https://swift-lemur-123.convex.cloud", "prod:swift-lemur-123|ab\u2028cd"),
("blank_key", "https://swift-lemur-123.convex.cloud", " "),
]
@@ -110,6 +112,7 @@ class TestValidateDeployUrl:
ok, err = validate_credentials(url, deploy_key)
assert not ok
assert err is not None
+ assert urlparse(url).hostname not in err
mock_get.assert_not_called()
@patch("products.warehouse_sources.backend.temporal.data_imports.sources.convex.convex.make_tracked_session")
@@ -136,9 +139,15 @@ class TestValidateDeployUrl:
"Streaming export requires the Convex Professional plan. See https://www.convex.dev/plans to upgrade."
)
+ @parameterized.expand(
+ [
+ ("unexpected_status", 400, "The Convex deployment rejected the request."),
+ ("unknown_deployment", 404, "PostHog couldn't find this Convex deployment."),
+ ]
+ )
@patch("products.warehouse_sources.backend.temporal.data_imports.sources.convex.convex.make_tracked_session")
- def test_validate_credentials_does_not_leak_url_on_http_error(self, mock_get):
- err_response = Mock(status_code=400)
+ def test_validate_credentials_does_not_leak_url_on_http_error(self, _name, status_code, expected, mock_get):
+ err_response = Mock(status_code=status_code)
err_response.json.return_value = {"code": "SomethingUnexpected"}
response = Mock()
response.raise_for_status.side_effect = HTTPError(response=err_response)
@@ -147,9 +156,10 @@ class TestValidateDeployUrl:
ok, err = validate_credentials("https://swift-lemur-123.convex.cloud", "prod:abc123")
assert not ok
assert err is not None
+ assert err.startswith(expected)
assert "swift-lemur-123" not in err
assert "convex.cloud" not in err
- assert "400" in err
+ assert str(status_code) not in err
@parameterized.expand(
[