Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/sentry/features/temporary.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ def register_temporary_features(manager: FeatureManager) -> None:
manager.add("organizations:gen-ai-features", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=True)
# Enable the 'translate' functionality for GenAI on the explore > traces page
manager.add("organizations:gen-ai-search-agent-translate", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=True)
# Enable AI search bar on the explore > metrics tab
manager.add("organizations:gen-ai-explore-metrics-search", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=True)
# Enable GenAI consent
manager.add("organizations:gen-ai-consent", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=True)
# Enable increased issue_owners rate limit for auto-assignment
Expand Down
16 changes: 14 additions & 2 deletions src/sentry/seer/endpoints/search_agent_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def send_search_agent_start_request(
user_email: str | None = None,
timezone: str | None = None,
model_name: str | None = None,
metric_context: dict[str, Any] | None = None,
viewer_context: SeerViewerContext | None = None,
) -> dict[str, Any]:
"""
Expand All @@ -87,6 +88,8 @@ def send_search_agent_start_request(
options: dict[str, Any] = {}
if model_name is not None:
options["model_name"] = model_name
if metric_context is not None:
options["metric_context"] = metric_context
if options:
body["options"] = options

Expand Down Expand Up @@ -129,15 +132,23 @@ def post(self, request: Request, organization: Organization) -> Response:
strategy = validated_data.get("strategy", "Traces")
options = validated_data.get("options") or {}
model_name = options.get("model_name")
metric_context = options.get("metric_context")

projects = self.get_projects(
request, organization, project_ids=set(validated_data["project_ids"])
)
project_ids = [project.id for project in projects]

if not features.has(
has_feature = features.has(
"organizations:gen-ai-search-agent-translate", organization, actor=request.user
):
)
if strategy == "Metrics":
has_feature = has_feature and features.has(
"organizations:gen-ai-explore-metrics-search",
organization,
actor=request.user,
)
Comment thread
cursor[bot] marked this conversation as resolved.
Comment thread
cursor[bot] marked this conversation as resolved.
if not has_feature:
return Response(
{"detail": "Feature flag not enabled"},
status=status.HTTP_403_FORBIDDEN,
Expand Down Expand Up @@ -174,6 +185,7 @@ def post(self, request: Request, organization: Organization) -> Response:
user_email=user_email,
timezone=timezone,
model_name=model_name,
metric_context=metric_context,
viewer_context=viewer_context,
)

Expand Down
7 changes: 5 additions & 2 deletions src/sentry/seer/endpoints/search_agent_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,12 @@ def get(self, request: Request, organization: Organization, run_id: str) -> Resp
}
}
"""
if not features.has(
has_feature = features.has(
"organizations:gen-ai-search-agent-translate", organization, actor=request.user
):
) or features.has(
"organizations:gen-ai-explore-metrics-search", organization, actor=request.user
)
Comment thread
sentry[bot] marked this conversation as resolved.
Comment thread
cursor[bot] marked this conversation as resolved.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

State endpoint OR logic defeats global killswitch intent

Medium Severity

The state endpoint uses or to combine the two feature flags, while the start endpoint uses and (per reviewer request) so gen-ai-search-agent-translate acts as a global killswitch. The or in the state endpoint undermines that intent — disabling gen-ai-search-agent-translate won't block state polling for orgs that only have gen-ai-explore-metrics-search enabled.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 77da5a6. Configure here.

if not has_feature:
return Response(
{"detail": "Feature flag not enabled"},
status=status.HTTP_403_FORBIDDEN,
Expand Down
Loading