: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(pipedrive): say what to do when credential validation fails (#101450)
Tom Owers5c8479197c52
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/pipedrive/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/pipedrive/source.pyindex 5037fa5861af..37893bec4801 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/pipedrive/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/pipedrive/source.py@@ -210,9 +210,22 @@ Deletions in Pipedrive are not applied to tables synced by webhook. Switch a tab# (schema_name is None) and only reject when validating a specific schema.if status == 403 and schema_name is None:return True, None- if status in (401, 403):- return False, "Invalid Pipedrive API token or insufficient permissions"- return False, "Could not validate Pipedrive credentials"+ if status == 401:+ return (+ False,+ "Your Pipedrive API token was rejected. Copy the token again from your Pipedrive "+ "personal preferences, then reconnect.",+ )+ if status == 403:+ return (+ False,+ "Your Pipedrive user doesn't have permission to read this data. Ask a Pipedrive "+ "admin to grant access, then try again.",+ )+ return (+ False,+ "Couldn't validate your Pipedrive credentials. Check your company domain and API token, then try again.",+ )def get_resumable_source_manager(self, inputs: SourceInputs) -> ResumableSourceManager[PipedriveResumeConfig]:return ResumableSourceManager[PipedriveResumeConfig](inputs, PipedriveResumeConfig)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/pipedrive/tests/test_pipedrive_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/pipedrive/tests/test_pipedrive_source.pyindex 47c4908d8736..fc9566404105 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/pipedrive/tests/test_pipedrive_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/pipedrive/tests/test_pipedrive_source.py@@ -71,15 +71,15 @@ class TestPipedriveSource:assert self.source.get_schemas(self.config, self.team_id, names=["nope"]) == []@pytest.mark.parametrize(- "status, schema_name, expected_valid, expected_message",+ "status, schema_name, expected_valid, expected_message_substring",[(200, None, True, None),(200, "deals", True, None),(403, None, True, None),- (403, "deals", False, "Invalid Pipedrive API token or insufficient permissions"),- (401, None, False, "Invalid Pipedrive API token or insufficient permissions"),- (500, None, False, "Could not validate Pipedrive credentials"),- (None, None, False, "Could not validate Pipedrive credentials"),+ (403, "deals", False, "doesn't have permission to read this data"),+ (401, None, False, "Pipedrive API token was rejected"),+ (500, None, False, "Couldn't validate your Pipedrive credentials"),+ (None, None, False, "Couldn't validate your Pipedrive credentials"),],)@mock.patch(@@ -91,14 +91,17 @@ class TestPipedriveSource:status: int | None,schema_name: str | None,expected_valid: bool,- expected_message: str | None,+ expected_message_substring: str | None,) -> None:mock_validate.return_value = statusis_valid, message = self.source.validate_credentials(self.config, self.team_id, schema_name)assert is_valid is expected_valid- assert message == expected_message+ if expected_message_substring is None:+ assert message is None+ else:+ assert message is not None and expected_message_substring in messagemock_validate.assert_called_once_with("acme", "token")@mock.patch(