: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(firebase): stop retrying auth sync when the service account lacks permission (#126210)
Tom Owers9e773a892c0c
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/firebase/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/firebase/source.pyindex b6a000793a8d..06a3fe018399 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/firebase/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/firebase/source.py@@ -261,6 +261,9 @@ class FirebaseSource(ResumableSource[FirebaseSourceConfig, FirebaseResumeConfig]# Identity Toolkit's `accounts:batchGet` rejects every request this way when the project# has no Firebase Authentication configuration at all — retrying can't create one."message=CONFIGURATION_NOT_FOUND": "This Firebase project doesn't have Firebase Authentication enabled, so PostHog can't read its Auth users. Enable Firebase Authentication in the Firebase console, or remove the Auth users table from this source.",+ # Identity Toolkit also rejects `accounts:batchGet` this way, as a 400 rather than a 403,+ # when the service account lacks the IAM role to list Auth users at all.+ "message=INSUFFICIENT_PERMISSION": "This service account can't read Firebase Authentication users. Grant it the Firebase Authentication Viewer role (or Firebase Viewer), then reconnect.",}@propertydiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/firebase/tests/test_firebase.py b/products/warehouse_sources/backend/temporal/data_imports/sources/firebase/tests/test_firebase.pyindex 62f089c64746..fd1a2ec0dadd 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/firebase/tests/test_firebase.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/firebase/tests/test_firebase.py@@ -675,6 +675,28 @@ class TestAuthUsersPagination:assert [state.cursor for state in manager.saved] == ["p2"]assert session.requests[0][1].endswith("/projects/demo-project/accounts:batchGet")+ def test_service_account_without_the_auth_role_is_a_non_retryable_error(self, logger: FilteringBoundLogger) -> None:+ # Identity Toolkit rejects a service account that lacks the IAM role to list Auth users+ # with a 400, not a 403 — `message=INSUFFICIENT_PERMISSION` is the only stable signal.+ session = FakeSession(+ request_responses=[+ FakeResponse(status_code=400, payload={"error": {"message": "INSUFFICIENT_PERMISSION"}})+ ],+ post_responses=[FakeResponse(payload=TOKEN_PAYLOAD)],+ )+ manager = FakeResumeManager()++ with pytest.raises(requests.HTTPError) as exc_info:+ list(iter_auth_users(session.as_session(), token_provider(session), credentials(), manager, logger))++ matches = [+ message+ for pattern, message in FirebaseSource().get_non_retryable_errors().items()+ if error_message_matches(str(exc_info.value), [pattern])+ ]+ assert matches and matches[0] is not None+ assert "Firebase Authentication" in matches[0]+def tenant(tenant_id: str) -> dict[str, Any]:return {"name": f"projects/demo-project/tenants/{tenant_id}", "displayName": tenant_id}