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(dub): give personal-API-key users workspace-key guidance at connect (#79419)

Tom Owers4937b37723bb
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/dub/dub.py b/products/warehouse_sources/backend/temporal/data_imports/sources/dub/dub.py
index d7d423134820..f0cda7ceada8 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/dub/dub.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/dub/dub.py
@@ -288,6 +288,15 @@ def validate_credentials(api_key: str) -> tuple[bool, str | None]:
return True, None
if res.status_code == 401:
return False, "Invalid Dub API key. Please check your key and try again."
- return False, _error_message(res)
+ message = _error_message(res)
+ # A personal (user) Dub API key fails the workspace-scoped probe with Dub's raw
+ # "workspaceId" error, which talks about a missing query param and links its API-refactoring
+ # docs — noise in the wizard. Point the user at a workspace key, which the field asks for.
+ if "workspaceid" in message.lower():
+ return False, (
+ "This looks like a personal Dub API key. Create a workspace API key in your Dub "
+ "workspace under Settings > API Keys, then try again."
+ )
+ return False, message
except Exception as e:
return False, str(e)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/dub/tests/test_dub.py b/products/warehouse_sources/backend/temporal/data_imports/sources/dub/tests/test_dub.py
index 6715008d23e9..595269739d43 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/dub/tests/test_dub.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/dub/tests/test_dub.py
@@ -309,6 +309,29 @@ class TestCredentialValidation:
assert valid is expected_valid
assert (message is None) is expected_valid
+ def test_personal_key_gets_workspace_guidance_not_raw_dub_error(self) -> None:
+ # A personal (non-workspace) key fails with Dub's raw "workspaceId" copy about a missing
+ # query param — replace it with guidance to use a workspace key.
+ response = _make_http_response(
+ {
+ "error": {
+ "code": "bad_request",
+ "message": "Workspace ID not found. Did you forget to include a `workspaceId` query parameter?",
+ }
+ },
+ 400,
+ )
+ with patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.dub.dub.make_tracked_session",
+ return_value=self._mock_session(response),
+ ):
+ valid, message = validate_credentials("dub_test")
+
+ assert valid is False
+ assert message is not None
+ assert "workspaceId" not in message
+ assert "workspace API key" in message
+
def test_check_endpoint_access_surfaces_api_denial_message(self) -> None:
response = _make_http_response(
{"error": {"code": "forbidden", "message": "Requires a Business plan or higher."}}, 403