Skip to content

fix: transport error normalization, sandbox URL encoding & hydration, and session/export parity - #152

Merged
AHarmlessPyro merged 4 commits into
mainfrom
fix/sdk-audit-improvements
Nov 10, 2026
Merged

AHarmlessPyro merged 4 commits into
mainfrom
fix/sdk-audit-improvements

Conversation

@shrisukhani

@shrisukhani shrisukhani commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR resolves several SDK audit issues and aligns python-sdk behavior with node-sdk:

  1. SyncTransport & AsyncTransport error normalization and timeout:

    • Updated put() and delete() in TransportStrategy, SyncTransport, and AsyncTransport to accept timeout: Optional[float] = None (matching post() and get()) and pass timeout=timeout to self.client.put / self.client.delete when provided.
    • Routed network exceptions in put() and delete() through normalize_network_error(e, "control", "Request failed", request_context("PUT"|"DELETE", url)) (re-raising KeyboardInterrupt, SystemExit, and asyncio.CancelledError).
    • Normalized httpx.RequestError in _handle_response via normalize_network_error(e, "control", "Request failed", request_context(response.request.method, str(response.request.url))) to preserve retryable, service, cause, and request_context.
  2. SandboxHandle._hydrate preserving startup_secrets:

    • Preserved existing self._detail.startup_secrets on SandboxHandle._hydrate(detail) when a refreshed SandboxDetail response omits startup_secrets (None), so sandbox.info() / sandbox.refresh() does not wipe startup_secrets.
    • Removed the unused _apply_runtime_session helper.
  3. URL-encode path parameters in SandboxManager / SandboxHandle:

    • Used urllib.parse.quote(str(...), safe="") when interpolating image, snapshot, build_id, and sandbox_id into URL paths in both sync and async SandboxManager.
  4. Missing exports & Session parity:

    • Exported HyperbrowserError and image build utilities (docker_build_context_fingerprint, DockerBuildContextChangedError, image_build_name, docker_image_digest, DockerCommandError) from hyperbrowser and hyperbrowser.image_builds.
    • Added "WebBotAuthParams" and "ProxyRoute" to __all__ in hyperbrowser.types.session.
    • Exported FILL_CREDENTIAL_TOOL_OPENAI, FILL_CREDENTIAL_TOOL_ANTHROPIC, FILL_CREDENTIAL_TOOL_GEMINI, FILL_CREDENTIAL_DESCRIPTION, and FILL_CREDENTIAL_SCHEMA in hyperbrowser.tools.
    • Added enable_webgl_fingerprinting: Optional[bool] (serialization_alias="enableWebglFingerprinting") to CreateSessionParams in both hyperbrowser.models.session and hyperbrowser.types.session.
    • Widened CaptchaSolverType to Union[Literal["visual"], str] so future backend solver types do not fail Pydantic validation.
    • Added get_active_sessions_count() (GET /sessions/active-count) returning GetActiveSessionsCountResponse to sync and async SessionManager.
    • Updated BrowserUseTool.runnable and BrowserUseTool.async_runnable to fall back to resp.error or "" when resp.data or final_result is absent, and validated that session_id is non-empty in SessionCredentialsManager.fill.

Testing

  • Added unit tests in tests/test_sdk_audit_fixes.py covering all changes.
  • Ran ruff check ., ruff format --check, and pytest tests --ignore=tests/sandbox/e2e (1065 passed).

Note

Medium Risk
Changes affect core transport error handling and many sandbox control URLs, but behavior is largely corrective and aligned with existing patterns; risk is moderate rather than high because auth/data paths are mostly validation and encoding fixes.

Overview
This 1.15.1 patch tightens HTTP client behavior, sandbox handling, and public API parity with the Node SDK.

Transport: put and delete now accept optional timeout and route failures through normalize_network_error (with request context), including in _handle_response for httpx.RequestError. asyncio.CancelledError is no longer wrapped as a network error.

Sandboxes: Path parameters (sandbox_id, image/snapshot/build IDs) are URL-encoded. _hydrate keeps existing startup_secrets when refreshed detail omits them; unused _apply_runtime_session is removed.

Sessions & models: Adds get_active_sessions_count() and GetActiveSessionsCountResponse; widens CaptchaSolverType; re-adds deprecated enable_webgl_fingerprinting for backward compatibility. Credential fill rejects empty session IDs client-side.

Exports & tooling: Top-level / image_builds expose Docker helpers and HyperbrowserError; DockerCommandError for missing Docker CLI; more fill-credential tool symbols in tools.__all__. BrowserUseTool returns resp.error when there is no final_result.

Tests in test_sdk_audit_fixes.py cover these behaviors.

Reviewed by Cursor Bugbot for commit 1aa5fed. Bugbot is set up for automated code reviews on this repo. Configure here.

@AHarmlessPyro

AHarmlessPyro commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 using default effort and found 1 potential issue.

Fix All in Cursor

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

Reviewed by Cursor Bugbot for commit 46ba9b2. Configure here.

Comment thread hyperbrowser/models/session.py Resolved
shrisukhani and others added 3 commits November 10, 2026 04:07
…elds

- Keep enable_webgl_fingerprinting for compatibility but document it as
  discontinued: the server ignores it.
- Remove max_concurrent_sessions / total_active_sessions_count from
  GetActiveSessionsCountResponse: /sessions/active-count only returns
  activeSessionsCount.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AHarmlessPyro
AHarmlessPyro added this pull request to the merge queue Nov 10, 2026
Merged via the queue into main with commit e90e191 Nov 10, 2026
13 checks passed
@AHarmlessPyro
AHarmlessPyro deleted the fix/sdk-audit-improvements branch November 10, 2026 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants