Browse Source

chore(features) Make features api_expose=False by default (#74674)

Going forward, feature flags have to be explicitly exposed in API
results. This will help keep API responses smaller and organization
details and project details responses faster by checking fewer feature
flags.
Mark Story 7 months ago
parent
commit
4309fe9eb6

+ 1 - 1
src/sentry/features/manager.py

@@ -168,7 +168,7 @@ class FeatureManager(RegisteredFeatureManager):
         cls: type[Feature] = Feature,
         entity_feature_strategy: bool | FeatureHandlerStrategy = False,
         default: bool = False,
-        api_expose: bool = True,
+        api_expose: bool = False,
     ) -> None:
         """
         Register a feature.

+ 1 - 1
src/sentry/features/temporary.py

@@ -191,7 +191,7 @@ def register_temporary_features(manager: FeatureManager):
     # Enables the search bar for metrics samples list
     manager.add("organizations:metrics-samples-list-search", OrganizationFeature, FeatureHandlerStrategy.REMOTE, api_expose=True)
     # Enable Session Stats down to a minute resolution
-    manager.add("organizations:minute-resolution-sessions", OrganizationFeature, FeatureHandlerStrategy.INTERNAL, default=True)
+    manager.add("organizations:minute-resolution-sessions", OrganizationFeature, FeatureHandlerStrategy.INTERNAL, default=True, api_expose=True)
     # Display CPU and memory metrics in transactions with profiles
     manager.add("organizations:mobile-cpu-memory-in-transactions", OrganizationFeature, FeatureHandlerStrategy.REMOTE, api_expose=True)
     # Adds the ttid & ttfd vitals to the frontend

+ 2 - 3
tests/sentry/api/serializers/test_organization.py

@@ -71,7 +71,6 @@ class OrganizationSerializerTest(TestCase):
             "dashboards-edit",
             "discover-basic",
             "discover-query",
-            "derive-code-mappings",
             "event-attachments",
             "integrations-alert-rule",
             "integrations-chat-unfurl",
@@ -106,8 +105,8 @@ class OrganizationSerializerTest(TestCase):
         user = self.create_user()
         organization = self.create_organization(owner=user)
 
-        features.add("organizations:test-feature", OrganizationFeature)
-        features.add("organizations:disabled-feature", OrganizationFeature)
+        features.add("organizations:test-feature", OrganizationFeature, api_expose=True)
+        features.add("organizations:disabled-feature", OrganizationFeature, api_expose=True)
         mock_batch.return_value = {
             f"organization:{organization.id}": {
                 "organizations:test-feature": True,

+ 2 - 4
tests/sentry/features/test_manager.py

@@ -81,10 +81,8 @@ class FeatureManagerTest(TestCase):
         manager.add("organizations:feature1", OrganizationFeature)
         manager.add("organizations:feature2", OrganizationFeature, api_expose=True)
         manager.add("organizations:feature3", OrganizationFeature, api_expose=False)
-        exposed = {"organizations:feature1", "organizations:feature2"}
-        hidden = {
-            "organizations:feature3",
-        }
+        exposed = {"organizations:feature2"}
+        hidden = {"organizations:feature1", "organizations:feature3"}
         assert set(manager.all(OrganizationFeature).keys()) == exposed | hidden
         assert (
             set(manager.all(feature_type=OrganizationFeature, api_expose_only=True).keys())