ref(seer): Add typed wrappers for remaining Seer API callsites#109607
Merged
ref(seer): Add typed wrappers for remaining Seer API callsites#109607
Conversation
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]>
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]>
gricha
approved these changes
Feb 27, 2026
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]>
Contributor
There was a problem hiding this comment.
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]>
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) ...
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Continues the work from #109589 to replace direct
make_signed_seer_api_requestcalls with TypedDict request types and thin wrapper functions across all remaining callsites insrc/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):
Scope:
make_signed_seer_api_requestto the new wrapper functions)code_review/utils.py: converted inlineconnection_from_url()to module-level singletonorganization_seer_explorer_update.pykept as-is because it dynamically spreadsrequest.dataNo behavior changes — purely a typing/structure refactor.