In version 24.11.1, a regression was introduced in PR #940 (commit 8d317ae) where the new ShelterPubsub implementation unconditionally tries to initialize a Google Cloud Pub/Sub client, even when Pub/Sub is not configured. This causes user signup to fail when using GitLab OAuth.
The previous implementation (commit 63bcae7) had a guard clause that only initialized Pub/Sub if both project_id and topic_id were configured. This guard was lost in the refactor.
Steps to reproduce:
- Deploy self-hosted with the
codecov/self-hosted-api:24.11.1 container image and without any Google Cloud Pub/Sub configuration
- Attempt to sign up using GitLab OAuth
- Signup fails with error:
google.auth.exceptions.DefaultCredentialsError: Your default credentials were not found
Fix suggestion:
Add a guard clause in ShelterPubsub.__init__ to only initialize the Pub/Sub client if both SHELTER_PUBSUB_PROJECT_ID and SHELTER_PUBSUB_SYNC_REPO_TOPIC_ID are configured.