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(bing_ads): dedupe "Invalid client data" error_map key (F601) (#63989)

Andrew Maguire525eefd5bc10
diff --git a/posthog/temporal/data_imports/sources/bing_ads/source.py b/posthog/temporal/data_imports/sources/bing_ads/source.py
index f4b0d3a7dc91..60ad33b461bf 100644
--- a/posthog/temporal/data_imports/sources/bing_ads/source.py
+++ b/posthog/temporal/data_imports/sources/bing_ads/source.py
@@ -70,37 +70,30 @@ class BingAdsSource(ResumableSource[BingAdsSourceConfig, BingAdsResumeConfig], O
"AuthenticationFailed": auth_friendly,
"InvalidCredentials": auth_friendly,
"OAuthTokenExpired": auth_friendly,
- # Bing rejects the SOAP request as invalid *after* auth succeeds — the configured Account ID
- # is wrong or the connected Microsoft Advertising user can't access it. The SDK raises this as
- # `suds.WebFault("Server raised fault: 'Invalid client data. Check the SOAP fault details for
- # more information. TrackingId: <uuid>.'")`. The fault is deterministic (the same bad request
- # always reproduces it), so retrying can't recover — the customer has to fix the Account ID or
- # grant the connected account access. Match the stable phrase only; the TrackingId is volatile.
- # This does not catch transient Bing faults like "Server raised fault: 'Internal Error'".
+ # Bing returns the generic SOAP fault "Invalid client data. Check the SOAP fault details for
+ # more information. TrackingId: <uuid>." for two distinct deterministic conditions, neither of
+ # which retrying can recover:
+ # - the request is rejected as invalid *after* auth succeeds — the configured Account ID is
+ # wrong, or the connected Microsoft Advertising user can't access it — raised by the SDK as
+ # `suds.WebFault("Server raised fault: 'Invalid client data...'")`;
+ # - CustomerManagementService.GetUser can't use the connected account (revoked/expired
+ # credentials, a work/school identity instead of a personal Microsoft account —
+ # WorkIdentityNotAvailable — or no access). GetUser takes no request parameters, so this is
+ # never a malformed-request bug on our side.
+ # Match the stable phrase only; the TrackingId is volatile. This does not catch transient Bing
+ # faults like "Server raised fault: 'Internal Error'".
"Invalid client data": (
- "Bing Ads rejected the request as invalid. This usually means the configured Account ID is "
- "incorrect, or the connected Bing Ads account does not have access to it. Please check the "
- "Account ID in your source settings and that the connected account can access it, then "
- "reconfigure your Bing Ads source."
+ "PostHog could not use the connected Bing Ads account (Microsoft returned 'Invalid client data'). "
+ "This usually means the configured Account ID is incorrect, the connected account's credentials are "
+ "no longer valid, or it does not have access to the Microsoft Advertising account. Please check the "
+ "Account ID in your source settings and reconnect your Bing Ads integration, making sure the "
+ "signed-in account can access the account in Microsoft Advertising."
),
# Integration row was deleted/disconnected while a scheduled job still references it.
# Raised by OAuthMixin.get_oauth_integration as `ValueError("Integration not found: <id>")`;
# the id is volatile, so match only the stable prefix. Retrying can't recreate the row —
# the customer has to reconnect.
"Integration not found": "The linked Bing Ads integration no longer exists. Please reconnect your Bing Ads integration.",
- # CustomerManagementService.GetUser returns the generic SOAP fault "Invalid client data.
- # Check the SOAP fault details for more information." when the connected account can't be
- # used — revoked/expired credentials, a work/school identity instead of a personal Microsoft
- # account (WorkIdentityNotAvailable), or no access to the Microsoft Advertising account.
- # GetUser takes no request parameters, so this is never a malformed-request bug on our side;
- # retrying can't recover it. When the specific code above is present in the fault detail it
- # matches first; this catches the generic umbrella message otherwise.
- "Invalid client data": (
- "PostHog could not use the connected Bing Ads account (Microsoft returned 'Invalid client data'). "
- "This usually means the account's credentials are no longer valid, or the Microsoft account does not "
- "have access to the Microsoft Advertising account. Please reconnect your Bing Ads integration and make "
- "sure the signed-in account can access the account in Microsoft Advertising."
- ),
# Deterministic credential/config errors raised in source_for_pipeline.
"Bing Ads access token not found": "Bing Ads OAuth access token is missing. Please reconnect your Bing Ads integration.",
"Bing Ads refresh token not found": "Bing Ads OAuth refresh token is missing. Please reconnect your Bing Ads integration.",