diff --git a/src/sentry/api/serializers/models/organization.py b/src/sentry/api/serializers/models/organization.py index 97b422d1d2bdbf..57fe4a7765e958 100644 --- a/src/sentry/api/serializers/models/organization.py +++ b/src/sentry/api/serializers/models/organization.py @@ -695,7 +695,13 @@ def serialize( # type: ignore[explicit-override, override] if sample_rate is not None: context["planSampleRate"] = sample_rate - desired_sample_rate, _ = get_org_sample_rate(org_id=obj.id, default_sample_rate=sample_rate) + if is_project_mode_sampling(obj): + desired_sample_rate = None + else: + desired_sample_rate, _ = get_org_sample_rate( + org_id=obj.id, default_sample_rate=sample_rate + ) + if desired_sample_rate is not None: context["desiredSampleRate"] = desired_sample_rate diff --git a/tests/sentry/api/endpoints/test_organization_details.py b/tests/sentry/api/endpoints/test_organization_details.py index 6172fd9cc8576a..f02afa413d9341 100644 --- a/tests/sentry/api/endpoints/test_organization_details.py +++ b/tests/sentry/api/endpoints/test_organization_details.py @@ -341,6 +341,8 @@ def test_is_dynamically_sampled_org_option(self): with self.feature({"organizations:dynamic-sampling-custom": True}): response = self.get_success_response(self.organization.slug) assert response.data["isDynamicallySampled"] + assert "planSampleRate" in response.data + assert "desiredSampleRate" in response.data self.organization.update_option( "sentry:sampling_mode", DynamicSamplingMode.ORGANIZATION.value @@ -365,6 +367,8 @@ def test_is_dynamically_sampled_proj_option(self): with self.feature({"organizations:dynamic-sampling-custom": True}): response = self.get_success_response(self.organization.slug) assert response.data["isDynamicallySampled"] + assert "planSampleRate" not in response.data + assert "desiredSampleRate" not in response.data def test_dynamic_sampling_custom_target_sample_rate(self): with self.feature({"organizations:dynamic-sampling-custom": True}):