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(meta_ads): classify code-100 "unsupported get request" as auth failure (#75431)

Tom Owers066c5ae1672a
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/meta_ads/meta_ads.py b/products/warehouse_sources/backend/temporal/data_imports/sources/meta_ads/meta_ads.py
index 6ecea7e36b98..4cdf413a7dcf 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/meta_ads/meta_ads.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/meta_ads/meta_ads.py
@@ -402,6 +402,13 @@ def _get_initial_request(url: str, params: dict) -> Response:
META_AUTH_ERROR_CODES = {102, 190}
META_PERMISSION_ERROR_CODES = {10, *range(200, 300)}
+# Meta also raises generic code 100 ("Invalid parameter") with this exact message when the
+# token's own account can no longer be resolved, e.g. the connected Facebook account was
+# deactivated or lost the app's granted access. Matched on message text rather than on code
+# 100 alone, since that code also covers genuine malformed-request bugs on our side, which
+# must keep surfacing as real errors rather than being reclassified as auth failures.
+META_UNSUPPORTED_GET_REQUEST_MESSAGE = "unsupported get request"
+
# Meta throttling codes. The request was rejected for its volume, not for being malformed, so the
# call is fine and the only fix is waiting — never a bug on our side.
# 4 — application request limit reached (our app, across all users).
@@ -447,7 +454,10 @@ def _is_permanent_auth_error(response: Response) -> bool:
until the user reconnects the integration.
"""
code = _meta_error_code(response)
- return code in META_AUTH_ERROR_CODES or code in META_PERMISSION_ERROR_CODES
+ if code in META_AUTH_ERROR_CODES or code in META_PERMISSION_ERROR_CODES:
+ return True
+ message = str(_meta_error_body(response).get("message") or "").lower()
+ return code == 100 and META_UNSUPPORTED_GET_REQUEST_MESSAGE in message
def _is_rate_limit_error(response: Response) -> bool:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/meta_ads/test_meta_ads.py b/products/warehouse_sources/backend/temporal/data_imports/sources/meta_ads/test_meta_ads.py
index e757903a8895..fd704f90b08d 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/meta_ads/test_meta_ads.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/meta_ads/test_meta_ads.py
@@ -1281,6 +1281,23 @@ class TestNonRetryableErrors:
({"error": {"code": 10}}, True),
({"error": {"code": 200}}, True),
({"error": {"code": 299}}, True),
+ # Real-world "(#100) Unsupported get request" — the token's own account could no
+ # longer be resolved, surfaced under the generic "Invalid parameter" code instead
+ # of one of the dedicated auth codes above.
+ (
+ {
+ "error": {
+ "message": "(#100) Unsupported get request. Please read the Graph API documentation "
+ "at https://developers.facebook.com/docs/graph-api",
+ "type": "OAuthException",
+ "code": 100,
+ }
+ },
+ True,
+ ),
+ # A different code-100 message is a genuine malformed-request bug, not an auth
+ # failure — it must not be swept into the same reclassification.
+ ({"error": {"message": "Invalid parameter", "code": 100}}, False),
# Transient / retryable errors — Meta still tags some of these OAuthException.
({"error": {"code": 2, "type": "OAuthException"}}, False),
({"error": {"code": 1, "error_subcode": 99}}, False),