From 6715237b11f4f1b8efee55e6357fdf7202a09ad4 Mon Sep 17 00:00:00 2001 From: Zachary Collins Date: Thu, 21 Sep 2023 14:08:13 -0700 Subject: [PATCH] ref(core): Protect saas from creating default projects --- src/sentry/receivers/core.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/sentry/receivers/core.py b/src/sentry/receivers/core.py index 882eb0894fea13..df697ed88e2a3e 100644 --- a/src/sentry/receivers/core.py +++ b/src/sentry/receivers/core.py @@ -16,6 +16,8 @@ from sentry.services.hybrid_cloud.util import region_silo_function from sentry.signals import post_upgrade, project_created from sentry.silo import SiloMode +from sentry.utils.env import in_test_environment +from sentry.utils.settings import is_self_hosted PROJECT_SEQUENCE_FIX = """ SELECT setval('sentry_project_id_seq', ( @@ -39,6 +41,10 @@ def wrapped(*args, **kwargs): def create_default_projects(**kwds): + if not in_test_environment() and not is_self_hosted(): + # No op in production SaaS environments. + return + create_default_project( # This guards against sentry installs that have SENTRY_PROJECT set to None, so # that they don't error after every migration. Specifically for single tenant.