Skip to content

ref(seer): Migrate remaining seer calls to urllib3 connection pools#109263

Merged
azulus merged 4 commits intomasterfrom
jstanley/ref-misc-make-signed-seer-api-request
Feb 25, 2026
Merged

ref(seer): Migrate remaining seer calls to urllib3 connection pools#109263
azulus merged 4 commits intomasterfrom
jstanley/ref-misc-make-signed-seer-api-request

Conversation

@azulus
Copy link
Member

@azulus azulus commented Feb 24, 2026

Migrate all remaining requests.post + sign_with_seer_secret calls to make_signed_seer_api_request with urllib3 connection pools, completing the migration started in #109205, #109224, and #109254.

Migrated callers (requests.post → connection pool):

  • tasks/explorer_context_engine_tasks.py
  • uptime/seer_assertions.py
  • seer/services/test_generation/impl.py (also adds signing that was previously missing)

SeerApiError cleanup (bare Exception → SeerApiError):

  • api/endpoints/seer_models.py
  • seer/supergroups.py
  • seer/trace_summary.py
  • tasks/seer.py
  • tasks/seer_explorer_index.py

After this change, no external requests.post or sign_with_seer_secret calls remain outside of make_signed_seer_api_request. The only remaining sign_with_seer_secret usage is the internal definition and call within signed_seer_api.py itself.

Note: explorer_service_map_utils.py has a _send_to_seer stub with a TODO comment — it doesn't make any actual requests yet.

azulus and others added 2 commits February 24, 2026 15:04
Replace requests.post with make_signed_seer_api_request in:
- supergroups.py: Supergroup embeddings
- trace_summary.py: Trace summarization
- tasks/seer.py & tasks/seer_explorer_index.py: Background tasks
- api/endpoints/seer_models.py: Seer models API

Update corresponding tests with new mocking patterns.

This completes the migration from requests to urllib3 connection pools
across all Seer integration code.

Co-Authored-By: Claude <noreply@anthropic.com>
Migrate all remaining `requests.post` + `sign_with_seer_secret` calls
to `make_signed_seer_api_request` with urllib3 connection pools, and
replace bare `Exception` raises with `SeerApiError` across all
cherry-picked files.

Migrated callers:
- explorer_context_engine_tasks (requests.post → connection pool)
- uptime/seer_assertions (requests.post → connection pool)
- seer/services/test_generation/impl (requests.post → connection pool)

SeerApiError cleanup:
- seer_models, supergroups, trace_summary, seer tasks, seer_explorer_index

After this change, no external `requests.post` or `sign_with_seer_secret`
calls remain outside of `make_signed_seer_api_request`.

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 Feb 24, 2026
Address Warden feedback:
- test_generation/impl.py: Handle response.data being None when
  decoding error response body, matching the pattern used in
  similar_issues.py and store_data.py
- uptime/seer_assertions.py: Catch urllib3 exceptions (MaxRetryError,
  TimeoutError) in addition to SeerApiError for network failures,
  preserving the graceful fallback behavior from the requests era

Co-Authored-By: Claude <noreply@anthropic.com>
- seer_models.py: Simplify `except (Exception, json.JSONDecodeError)`
  to `except Exception:` since JSONDecodeError is a subclass. Remove
  unused json import.
- test_seer_models.py: Replace `requests.get` mocks with
  `make_signed_seer_api_request` mocks (requests import was removed).
- test_seer.py: Replace `@responses.activate` with
  `make_signed_seer_api_request` mocks (responses library doesn't
  intercept urllib3).

Co-Authored-By: Claude <noreply@anthropic.com>
@azulus azulus marked this pull request as ready for review February 25, 2026 00:02
@azulus azulus requested review from a team as code owners February 25, 2026 00:02
Copy link
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.

except TimeoutError:
logger.warning("Timeout when fetching models from Seer")
raise SeerTimeoutError()
except (requests.exceptions.RequestException, json.JSONDecodeError):
Copy link
Contributor

Choose a reason for hiding this comment

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

Catching wrong TimeoutError type; urllib3 timeouts uncaught

High Severity

The except TimeoutError clause catches Python's built-in TimeoutError, but make_signed_seer_api_request uses urllib3 which raises urllib3.exceptions.TimeoutError — a completely separate class that does not inherit from the built-in TimeoutError. As a result, urllib3 timeout errors will never be caught here and will instead fall through to except Exception, returning a 502 SeerConnectionError instead of the intended 504 SeerTimeoutError. Notably, uptime/seer_assertions.py in this same PR correctly imports and catches urllib3.exceptions.TimeoutError as Urllib3TimeoutError.

Fix in Cursor Fix in Web

@azulus azulus merged commit 1730e13 into master Feb 25, 2026
78 checks passed
@azulus azulus deleted the jstanley/ref-misc-make-signed-seer-api-request branch February 25, 2026 00:18
@github-actions github-actions bot locked and limited conversation to collaborators Mar 12, 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