ref(seer): Propagate viewer_context to explorer Seer call sites#109716
Merged
ref(seer): Propagate viewer_context to explorer Seer call sites#109716
Conversation
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Missing viewer_context for state request call sites
- I updated explorer state-fetching helpers and their call sites to propagate
viewer_contextintomake_explorer_state_request, and adjusted tests to assert the new argument flow.
- I updated explorer state-fetching helpers and their call sites to propagate
Or push these changes by commenting:
@cursor push 35a696c929
Preview (35a696c929)
diff --git a/src/sentry/seer/explorer/client.py b/src/sentry/seer/explorer/client.py
--- a/src/sentry/seer/explorer/client.py
+++ b/src/sentry/seer/explorer/client.py
@@ -401,9 +401,15 @@
TimeoutError: If polling exceeds poll_timeout when blocking=True
"""
if blocking:
- state = poll_until_done(run_id, self.organization, poll_interval, poll_timeout)
+ state = poll_until_done(
+ run_id,
+ self.organization,
+ poll_interval,
+ poll_timeout,
+ viewer_context=self.viewer_context,
+ )
else:
- state = fetch_run_status(run_id, self.organization)
+ state = fetch_run_status(run_id, self.organization, viewer_context=self.viewer_context)
return state
@@ -548,7 +554,7 @@
start_time = time.time()
while True:
- state = fetch_run_status(run_id, self.organization)
+ state = fetch_run_status(run_id, self.organization, viewer_context=self.viewer_context)
# Check if any PRs are still being created
any_creating = any(
diff --git a/src/sentry/seer/explorer/client_utils.py b/src/sentry/seer/explorer/client_utils.py
--- a/src/sentry/seer/explorer/client_utils.py
+++ b/src/sentry/seer/explorer/client_utils.py
@@ -224,10 +224,14 @@
}
-def fetch_run_status(run_id: int, organization: Organization) -> SeerRunState:
+def fetch_run_status(
+ run_id: int,
+ organization: Organization,
+ viewer_context: SeerViewerContext | None = None,
+) -> SeerRunState:
"""Fetch current run status from Seer."""
body = ExplorerStateRequest(run_id=run_id, organization_id=organization.id)
- response = make_explorer_state_request(body)
+ response = make_explorer_state_request(body, viewer_context=viewer_context)
if response.status >= 400:
raise SeerApiError("Seer request failed", response.status)
@@ -245,12 +249,13 @@
organization: Organization,
poll_interval: float,
poll_timeout: float,
+ viewer_context: SeerViewerContext | None = None,
) -> SeerRunState:
"""Poll the run status until completion, error, awaiting_user_input, or timeout."""
start_time = time.time()
while True:
- result = fetch_run_status(run_id, organization)
+ result = fetch_run_status(run_id, organization, viewer_context=viewer_context)
# Check if run is complete
if result.status in ("completed", "error", "awaiting_user_input"):
diff --git a/tests/sentry/seer/explorer/test_explorer_client.py b/tests/sentry/seer/explorer/test_explorer_client.py
--- a/tests/sentry/seer/explorer/test_explorer_client.py
+++ b/tests/sentry/seer/explorer/test_explorer_client.py
@@ -265,7 +265,9 @@
assert result.run_id == 123
assert result.status == "processing"
- mock_fetch.assert_called_once_with(123, self.organization)
+ mock_fetch.assert_called_once_with(
+ 123, self.organization, viewer_context=client.viewer_context
+ )
@patch("sentry.seer.explorer.client.has_seer_access_with_detail")
@patch("sentry.seer.explorer.client.poll_until_done")
@@ -285,7 +287,9 @@
assert result.run_id == 123
assert result.status == "completed"
- mock_poll.assert_called_once_with(123, self.organization, 1.0, 30.0)
+ mock_poll.assert_called_once_with(
+ 123, self.organization, 1.0, 30.0, viewer_context=client.viewer_context
+ )
@patch("sentry.seer.explorer.client.has_seer_access_with_detail")
@patch("sentry.seer.explorer.client.fetch_run_status")
gricha
approved these changes
Mar 3, 2026
0e0d7e2 to
7c09d29
Compare
Pass SeerViewerContext to Seer API wrapper call sites in the explorer module. SeerExplorerClient builds context from self.organization and self.user. Service map utils use org_id only.
7c09d29 to
7375eb1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Pass
SeerViewerContextto all Seer API wrapper call sites in the explorer module.PR #109697 added an optional
viewer_contextparameter to all Seer API wrapper functions. This PR updates the explorer module call sites:self.organizationandself.userin__init__, passes tostart_run,continue_run,get_runs,push_changes_send_to_seer): Passorganization_idonly (no user available)No behavior change —
viewer_contextdefaults toNonewhich preserves existing behavior.Co-Authored-By: Claude noreply@anthropic.com