Skip to content

ref(seer): Propagate viewer_context to Seer endpoint call sites#109723

Merged
azulus merged 2 commits intomasterfrom
viewer-context/seer-endpoints
Mar 4, 2026
Merged

ref(seer): Propagate viewer_context to Seer endpoint call sites#109723
azulus merged 2 commits intomasterfrom
viewer-context/seer-endpoints

Conversation

@azulus
Copy link
Member

@azulus azulus commented Mar 2, 2026

Pass SeerViewerContext to Seer API wrapper call sites in various Seer endpoint modules.

PR #109697 added an optional viewer_context parameter to all Seer API wrapper functions. This PR updates 8 files:

  • compare.py + organization_trace_item_attributes_ranked.py: Compare distributions
  • issue_view_title_generate.py: Title generation from query
  • search_agent_state.py, search_agent_start.py: Search agent endpoints
  • trace_explorer_ai_query.py, trace_explorer_ai_translate_agentic.py, trace_explorer_ai_setup.py: Trace explorer AI endpoints

All are API endpoints with both organization_id and user_id available. Intermediate functions thread viewer_context through to the underlying wrapper calls.

No behavior change — viewer_context defaults to None which preserves existing behavior.

Co-Authored-By: Claude noreply@anthropic.com

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 2, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2026

Backend Test Failures

Failures on 9a4bd5b in this run:

tests/sentry/seer/endpoints/test_trace_explorer_ai_query.py::TraceExplorerAIQueryTest::test_query_successfullog
tests/sentry/seer/endpoints/test_trace_explorer_ai_query.py:50: in test_query_successful
    mock_send_request.assert_called_once_with(
/opt/hostedtoolcache/Python/3.13.1/x64/lib/python3.13/unittest/mock.py:989: in assert_called_once_with
    return self.assert_called_with(*args, **kwargs)
/opt/hostedtoolcache/Python/3.13.1/x64/lib/python3.13/unittest/mock.py:977: in assert_called_with
    raise AssertionError(_error_message()) from cause
E   AssertionError: expected call not found.
E   Expected: send_translate_request(4557725032972288, 'fair-katydid', [4557725032972288], 'Find slow transactions')
E     Actual: send_translate_request(4557725032972288, 'fair-katydid', [4557725032972288], 'Find slow transactions', viewer_context={'organization_id': 4557725032972288, 'user_id': 756})
tests/sentry/seer/endpoints/test_trace_explorer_ai_setup.py::TraceExplorerAISetupTest::test_simplelog
tests/sentry/seer/endpoints/test_trace_explorer_ai_setup.py:24: in test_simple
    mock_fire_setup_request.assert_called_once_with(self.organization.id, [self.project.id])
/opt/hostedtoolcache/Python/3.13.1/x64/lib/python3.13/unittest/mock.py:989: in assert_called_once_with
    return self.assert_called_with(*args, **kwargs)
/opt/hostedtoolcache/Python/3.13.1/x64/lib/python3.13/unittest/mock.py:977: in assert_called_with
    raise AssertionError(_error_message()) from cause
E   AssertionError: expected call not found.
E   Expected: fire_setup_request(4557725033889792, [4557725033955328])
E     Actual: fire_setup_request(4557725033889792, [4557725033955328], viewer_context={'organization_id': 4557725033889792, 'user_id': 810})
tests/sentry/seer/endpoints/test_trace_explorer_ai_translate_agentic.py::SearchAgentTranslateEndpointTest::test_translate_successfullog
tests/sentry/seer/endpoints/test_trace_explorer_ai_translate_agentic.py:48: in test_translate_successful
    mock_send_request.assert_called_once_with(
/opt/hostedtoolcache/Python/3.13.1/x64/lib/python3.13/unittest/mock.py:989: in assert_called_once_with
    return self.assert_called_with(*args, **kwargs)
/opt/hostedtoolcache/Python/3.13.1/x64/lib/python3.13/unittest/mock.py:977: in assert_called_with
    raise AssertionError(_error_message()) from cause
E   AssertionError: expected call not found.
E   Expected: send_translate_agentic_request(4557725039656960, 'actual-python', [4557725039722496], 'Find slow transactions', strategy='Traces', model_name=None)
E     Actual: send_translate_agentic_request(4557725039656960, 'actual-python', [4557725039722496], 'Find slow transactions', strategy='Traces', model_name=None, viewer_context={'organization_id': 4557725039656960, 'user_id': 831})
tests/sentry/seer/endpoints/test_trace_explorer_ai_setup.py::TraceExplorerAISetupTest::test_empty_projects_still_calls_seerlog
tests/sentry/seer/endpoints/test_trace_explorer_ai_setup.py:72: in test_empty_projects_still_calls_seer
    mock_fire_setup_request.assert_called_once_with(self.organization.id, [])
/opt/hostedtoolcache/Python/3.13.1/x64/lib/python3.13/unittest/mock.py:989: in assert_called_once_with
    return self.assert_called_with(*args, **kwargs)
/opt/hostedtoolcache/Python/3.13.1/x64/lib/python3.13/unittest/mock.py:977: in assert_called_with
    raise AssertionError(_error_message()) from cause
E   AssertionError: expected call not found.
E   Expected: fire_setup_request(4557725061742592, [])
E     Actual: fire_setup_request(4557725061742592, [], viewer_context={'organization_id': 4557725061742592, 'user_id': 841})

@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2026

Backend Test Failures

Failures on 81f866f in this run:

tests/sentry/seer/endpoints/test_trace_explorer_ai_query.py::TraceExplorerAIQueryTest::test_query_successfullog
tests/sentry/seer/endpoints/test_trace_explorer_ai_query.py:50: in test_query_successful
    mock_send_request.assert_called_once_with(
/opt/hostedtoolcache/Python/3.13.1/x64/lib/python3.13/unittest/mock.py:989: in assert_called_once_with
    return self.assert_called_with(*args, **kwargs)
/opt/hostedtoolcache/Python/3.13.1/x64/lib/python3.13/unittest/mock.py:977: in assert_called_with
    raise AssertionError(_error_message()) from cause
E   AssertionError: expected call not found.
E   Expected: send_translate_request(4557725440737280, 'complete-tahr', [4557725440737280], 'Find slow transactions')
E     Actual: send_translate_request(4557725440737280, 'complete-tahr', [4557725440737280], 'Find slow transactions', viewer_context={'organization_id': 4557725440737280, 'user_id': 760})
tests/sentry/seer/endpoints/test_trace_explorer_ai_setup.py::TraceExplorerAISetupTest::test_simplelog
tests/sentry/seer/endpoints/test_trace_explorer_ai_setup.py:24: in test_simple
    mock_fire_setup_request.assert_called_once_with(self.organization.id, [self.project.id])
/opt/hostedtoolcache/Python/3.13.1/x64/lib/python3.13/unittest/mock.py:989: in assert_called_once_with
    return self.assert_called_with(*args, **kwargs)
/opt/hostedtoolcache/Python/3.13.1/x64/lib/python3.13/unittest/mock.py:977: in assert_called_with
    raise AssertionError(_error_message()) from cause
E   AssertionError: expected call not found.
E   Expected: fire_setup_request(4557725442048000, [4557725442048000])
E     Actual: fire_setup_request(4557725442048000, [4557725442048000], viewer_context={'organization_id': 4557725442048000, 'user_id': 810})
tests/sentry/seer/endpoints/test_trace_explorer_ai_translate_agentic.py::SearchAgentTranslateEndpointTest::test_translate_successfullog
tests/sentry/seer/endpoints/test_trace_explorer_ai_translate_agentic.py:48: in test_translate_successful
    mock_send_request.assert_called_once_with(
/opt/hostedtoolcache/Python/3.13.1/x64/lib/python3.13/unittest/mock.py:989: in assert_called_once_with
    return self.assert_called_with(*args, **kwargs)
/opt/hostedtoolcache/Python/3.13.1/x64/lib/python3.13/unittest/mock.py:977: in assert_called_with
    raise AssertionError(_error_message()) from cause
E   AssertionError: expected call not found.
E   Expected: send_translate_agentic_request(4557725444800512, 'complete-muskrat', [4557725444800512], 'Find slow transactions', strategy='Traces', model_name=None)
E     Actual: send_translate_agentic_request(4557725444800512, 'complete-muskrat', [4557725444800512], 'Find slow transactions', strategy='Traces', model_name=None, viewer_context={'organization_id': 4557725444800512, 'user_id': 831})
tests/sentry/seer/endpoints/test_trace_explorer_ai_setup.py::TraceExplorerAISetupTest::test_empty_projects_still_calls_seerlog
tests/sentry/seer/endpoints/test_trace_explorer_ai_setup.py:72: in test_empty_projects_still_calls_seer
    mock_fire_setup_request.assert_called_once_with(self.organization.id, [])
/opt/hostedtoolcache/Python/3.13.1/x64/lib/python3.13/unittest/mock.py:989: in assert_called_once_with
    return self.assert_called_with(*args, **kwargs)
/opt/hostedtoolcache/Python/3.13.1/x64/lib/python3.13/unittest/mock.py:977: in assert_called_with
    raise AssertionError(_error_message()) from cause
E   AssertionError: expected call not found.
E   Expected: fire_setup_request(4557725446569984, [])
E     Actual: fire_setup_request(4557725446569984, [], viewer_context={'organization_id': 4557725446569984, 'user_id': 841})

@azulus azulus marked this pull request as ready for review March 3, 2026 19:06
@azulus azulus requested review from a team as code owners March 3, 2026 19:06
azulus added 2 commits March 3, 2026 17:15
Pass SeerViewerContext to Seer API wrapper call sites in various Seer
endpoints (compare, issue view title, search agent, trace explorer).
All endpoints have org+user context. Intermediate functions thread
the parameter through.
@azulus azulus force-pushed the viewer-context/seer-endpoints branch from d2691d7 to 0c37ea9 Compare March 4, 2026 01:16
@azulus azulus merged commit 179b8b0 into master Mar 4, 2026
76 checks passed
@azulus azulus deleted the viewer-context/seer-endpoints branch March 4, 2026 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants