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(data-warehouse): tell people what to do when Hookdeck rejects a key (#96283)

Tom Owers98436537a8a7
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/hookdeck/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/hookdeck/source.py
index 3f599918015f..bc504a657935 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/hookdeck/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/hookdeck/source.py
@@ -128,15 +128,24 @@ API keys are scoped to a single Hookdeck project, so connect one PostHog source
if is_valid:
return True, None
if status == 401:
- return False, "Invalid Hookdeck API key"
+ return False, (
+ "Your Hookdeck API key is invalid or has been rotated. Copy the current key from "
+ "Settings → Project → Secrets in Hookdeck, then enter it again."
+ )
if status == 403:
# A project API key reaches every resource in its own project, so a 403 at source-create
# is more likely a plan restriction on one resource than a bad key. Only fail when a
# specific table was asked for.
if schema_name is not None:
- return False, "Your Hookdeck API key can't access this resource"
+ return False, (
+ "Your Hookdeck API key can't access this resource. Check that the key belongs to the "
+ "project you want to sync."
+ )
return True, None
- return False, "Could not connect to the Hookdeck API"
+ return False, (
+ "PostHog could not reach Hookdeck to check your API key. Wait a moment and try again, or "
+ "check Hookdeck's status page."
+ )
def get_resumable_source_manager(self, inputs: SourceInputs) -> ResumableSourceManager[HookdeckResumeConfig]:
return ResumableSourceManager[HookdeckResumeConfig](inputs, HookdeckResumeConfig)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/hookdeck/tests/test_hookdeck_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/hookdeck/tests/test_hookdeck_source.py
index cdd9a420b377..5b001a8542ad 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/hookdeck/tests/test_hookdeck_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/hookdeck/tests/test_hookdeck_source.py
@@ -11,6 +11,10 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.hookdeck.s
from products.warehouse_sources.backend.temporal.data_imports.sources.hookdeck.source import HookdeckSource
SOURCE_MODULE = "products.warehouse_sources.backend.temporal.data_imports.sources.hookdeck.source"
+UNREACHABLE_MESSAGE = (
+ "PostHog could not reach Hookdeck to check your API key. Wait a moment and try again, or "
+ "check Hookdeck's status page."
+)
INCREMENTAL_ENDPOINTS = sorted(name for name, c in HOOKDECK_ENDPOINTS.items() if c.incremental_fields)
FULL_REFRESH_ENDPOINTS = sorted(name for name, c in HOOKDECK_ENDPOINTS.items() if not c.incremental_fields)
@@ -84,12 +88,28 @@ class TestHookdeckSource:
"probe_result, schema_name, expected",
[
((True, 200), None, (True, None)),
- ((False, 401), None, (False, "Invalid Hookdeck API key")),
+ (
+ (False, 401),
+ None,
+ (
+ False,
+ "Your Hookdeck API key is invalid or has been rotated. Copy the current key from "
+ "Settings → Project → Secrets in Hookdeck, then enter it again.",
+ ),
+ ),
# A 403 at source-create is a per-resource restriction, not a bad key.
((False, 403), None, (True, None)),
- ((False, 403), "events", (False, "Your Hookdeck API key can't access this resource")),
- ((False, None), None, (False, "Could not connect to the Hookdeck API")),
- ((False, 500), None, (False, "Could not connect to the Hookdeck API")),
+ (
+ (False, 403),
+ "events",
+ (
+ False,
+ "Your Hookdeck API key can't access this resource. Check that the key belongs to the "
+ "project you want to sync.",
+ ),
+ ),
+ ((False, None), None, (False, UNREACHABLE_MESSAGE)),
+ ((False, 500), None, (False, UNREACHABLE_MESSAGE)),
],
)
@mock.patch(f"{SOURCE_MODULE}.validate_hookdeck_credentials")