Skip to content

ref(seer): Add typed wrappers for remaining Seer API callsites#109607

Merged
azulus merged 6 commits intomasterfrom
jstanley/ref-seerializers-3
Feb 27, 2026
Merged

ref(seer): Add typed wrappers for remaining Seer API callsites#109607
azulus merged 6 commits intomasterfrom
jstanley/ref-seerializers-3

Conversation

@azulus
Copy link
Copy Markdown
Member

@azulus azulus commented Feb 27, 2026

Continues the work from #109589 to replace direct make_signed_seer_api_request calls with TypedDict request types and thin wrapper functions across all remaining callsites in src/sentry/seer/.

Motivation: The previous PR added typed wrappers for a few callsites. This completes the effort by covering ~40 remaining callsites across anomaly detection, autofix, explorer, breakpoints, similarity, code review, and the signed_seer_api connection pools. Each API endpoint now has a TypedDict for its request body and a wrapper function that handles serialization and routing, replacing untyped dicts with inline serialization and hardcoded paths.

Pattern (unchanged from #109589):

class SomeRequest(TypedDict):
    field: int

def make_some_request(
    body: SomeRequest,
    connection_pool: HTTPConnectionPool | None = None,
    timeout: int | float | None = None,
) -> BaseHTTPResponse:
    return make_signed_seer_api_request(
        connection_pool or default_pool,
        "/v1/some/endpoint",
        body=orjson.dumps(body),
        timeout=timeout,
    )

Scope:

  • ~30 new TypedDicts and ~30 new wrapper functions
  • 28 source files updated (wrappers + callsites)
  • 8 test files updated (mock targets changed from make_signed_seer_api_request to the new wrapper functions)
  • code_review/utils.py: converted inline connection_from_url() to module-level singleton
  • One exception: organization_seer_explorer_update.py kept as-is because it dynamically spreads request.data

No behavior changes — purely a typing/structure refactor.

Continues the work from #109589 to replace direct
make_signed_seer_api_request calls with TypedDict request types
and thin wrapper functions across all remaining callsites in
src/sentry/seer/.

This adds ~30 TypedDicts and ~30 wrapper functions covering
anomaly detection, autofix, explorer, breakpoints, similarity,
code review, and signed_seer_api connection pools. Callsites
now construct typed request bodies instead of untyped dicts,
and wrappers handle serialization and routing internally.

Also converts the code_review connection pool from inline
creation to a module-level singleton.

Co-Authored-By: Claude <[email protected]>
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Feb 27, 2026
Correct field types in FixabilityScoreRequest (summary: dict not str),
ExplorerRunsRequest (start/end: datetime not str), and cast user.id to
int in ExplorerClient.get_runs().

Co-Authored-By: Claude <[email protected]>
Mypy reports that self.user.id can be None (AnonymousUser), so add
an explicit is-not-None guard before the int() conversion.

Co-Authored-By: Claude <[email protected]>
Update test mocks that were missed in the initial refactor:
- test_organization_coding_agents: mock make_store_coding_agent_states_request
- test_utils (autofix): access body from kwargs instead of positional args
- test_validators (incidents): mock make_store_data_request instead of
  connection_pool.urlopen

Co-Authored-By: Claude <[email protected]>
@azulus azulus marked this pull request as ready for review February 27, 2026 22:35
@azulus azulus requested review from a team as code owners February 27, 2026 22:35
The refactor to typed wrappers accidentally dropped the
retries=Retry(total=2, backoff_factor=0.5) parameter from the
get_project_seer_preferences() call. Add retries parameter support
to make_get_project_preference_request and restore the retry config.

Co-Authored-By: Claude <[email protected]>
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Remove dead seer_anomaly_detection_connection_pool and its unused
imports (connection_from_url, settings). The module now delegates to
make_store_data_request from store_data.py which has its own pool.

Co-Authored-By: Claude <[email protected]>
@azulus azulus merged commit 3d9366e into master Feb 27, 2026
76 checks passed
@azulus azulus deleted the jstanley/ref-seerializers-3 branch February 27, 2026 23:29
jan-auer added a commit that referenced this pull request Mar 2, 2026
…ept-encoding

* origin/master: (63 commits)
  fix(api): Add missing cursor query parameter to paginated endpoint OpenAPI schemas (#109642)
  docs(sentry-apps): Add sentryAppId to sentry-app-installations API schema (#109628)
  feat(occurrences on eap): Implement double reads from EAP in organization events trace API endpoint (#109391)
  feat(occurrences on eap): Implement double reads from EAP for reprocessing2 flow (#109345)
  feat(ci): report backend test fails (#109543)
  feat(seer): Add signed viewer context header to Seer API requests (#109626)
  devenv: cleanup devenv-managed uv (#109617)
  feat(seer): Iterate on the instructions at the top of seer settings pages (#109586)
  ref(seer): Add typed wrappers for remaining Seer API callsites (#109607)
  feat(preprod): Make snapshots endpoint org scoped (#109575)
  chore: capture exception (#109620)
  fix(formatting): run ruff format (#109618)
  feat(preprod): Create admin gated recompare snapshots endpoint (#109546)
  feat(cells): expand locality/cell distinction (#109538)
  feat(cells): add db migration for synapse (#109615)
  feat(preprod): Add public install-details endpoint and shared utilities (#109583)
  fix(tests): Fix flaky test_cross_trace_query_with_spans_and_logs (#109572)
  fix(grouping): Resolve mypy possibly-undefined errors in grouphash caching (#109602)
  fix(dashboards): Default axisRange to auto for existing widgets in builder (#109598)
  fix(billing): Fix category display names in pending changes (#109612)
  ...
@github-actions github-actions bot locked and limited conversation to collaborators Mar 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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