Skip to content

Conversation

@dobrac
Copy link
Contributor

@dobrac dobrac commented Nov 15, 2025

add basic pyright type checking


Note

Introduce Pyright type checking and update SDK types/optionals, auth handling, and MCP/request models with minor runtime safeguards.

  • Tooling/Config:
    • Add pyright to dev dependencies, Makefile lint target, and new [tool.pyright] config in pyproject.toml.
    • Update poetry.lock accordingly (adds pyright, nodeenv; metadata tweaks).
  • API/Client:
    • Type annotations tightened (e.g., Response[Any], typed headers) and stricter auth token checks in ApiClient.
  • Connection/URLs:
    • Refactor ConnectionConfig: expose sandbox_url, adjust get_sandbox_url() to honor env/override, and return typed dict[str, Any] from get_api_params().
  • Sandbox Core:
    • Make sandbox_domain non-optional at instance level (fallback to SDK domain); propagate optional domain/envd_access_token handling when connecting/creating (checks for Unset).
  • Commands (sync/async):
    • Accept optional user; default to default_username for older envd versions (ENVD_DEFAULT_USER).
    • Maintain stdin compatibility checks and pass possibly-optional user to auth headers.
  • Sandbox API (sync/async):
    • Build MCP payload via McpType0(**mcp); pass UNSET when absent.
    • Add guards for res.parsed is None; adjust metrics start/end to use UNSET.
  • Template (sync/async):
    • Normalize resolveSymlinks handling (explicit defaulting to RESOLVE_SYMLINKS).
  • Public API tidy:
    • Reorder and update exports in e2b/__init__.py (no behavior change).

Written by Cursor Bugbot for commit 065320a. This will update automatically on new commits. Configure here.

@dobrac dobrac added the Improvement Improvement for current functionality label Nov 15, 2025
@changeset-bot
Copy link

changeset-bot bot commented Nov 15, 2025

⚠️ No Changeset found

Latest commit: 065320a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dobrac dobrac force-pushed the add-python-type-checking branch from 6be9d29 to d96f488 Compare November 15, 2025 12:07
@dobrac dobrac force-pushed the add-python-type-checking branch from d96f488 to 065320a Compare November 15, 2025 12:07
@dobrac dobrac marked this pull request as ready for review November 15, 2025 12:08
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 134 to +139
return self._get_request_timeout(self.request_timeout, request_timeout)

def get_sandbox_url(self, sandbox_id: str, sandbox_domain: str) -> str:
if self._sandbox_url:
return self._sandbox_url
url = self._sandbox_url()
if url is not None:
return url

Choose a reason for hiding this comment

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

P1 Badge Custom sandbox_url option ignored

The constructor now assigns the supplied sandbox_url to self.sandbox_url, but get_sandbox_url() still calls the _sandbox_url() static helper and never uses the instance attribute. Callers that pass a custom sandbox_url (for example to point at a self‑hosted envd) will have their override dropped and always connect to the default host. This regresses configuration flexibility; get_sandbox_url should read the stored value before falling back to the default.

Useful? React with 👍 / 👎.

Comment on lines 164 to 168
metadata=metadata or {},
timeout=timeout,
env_vars=env_vars or {},
mcp=mcp or UNSET,
mcp=McpType0(**mcp) if mcp is not None else UNSET,
secure=secure,

Choose a reason for hiding this comment

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

P1 Badge Async sandbox MCP creation raises TypeError

When building the request body, mcp=McpType0(**mcp) is used. The generated McpType0 class has no keyword parameters (__init__ accepts none because it only stores additional_properties), so any non‑empty dict causes TypeError: __init__() got an unexpected keyword argument … before the request is sent. Creating a sandbox with an MCP configuration now crashes. Convert via McpType0.from_dict(mcp) or pass the dict through unchanged.

Useful? React with 👍 / 👎.

Comment on lines 163 to 167
metadata=metadata or {},
timeout=timeout,
env_vars=env_vars or {},
mcp=mcp or UNSET,
mcp=McpType0(**mcp) if mcp is not None else UNSET,
secure=secure,

Choose a reason for hiding this comment

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

P1 Badge Sync sandbox MCP creation raises TypeError

The synchronous sandbox API mirrors the async change, calling McpType0(**mcp) when a configuration is provided. Because McpType0’s initializer does not accept arbitrary keys, any attempt to pass an MCP configuration raises TypeError and the sandbox is never created. This breaks the Sandbox.create workflow for MCP users. Use McpType0.from_dict(mcp) or pass the dictionary directly.

Useful? React with 👍 / 👎.

def get_sandbox_url(self, sandbox_id: str, sandbox_domain: str) -> str:
if self._sandbox_url:
return self._sandbox_url
url = self._sandbox_url()
Copy link

Choose a reason for hiding this comment

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

Bug: Incorrect URL access bypasses cache.

The method calls self._sandbox_url() (the static method) instead of accessing self.sandbox_url (the instance attribute). This bypasses the cached value set in __init__ at line 119, causing the environment variable to be read on every call instead of using the stored value. The instance attribute was renamed from _sandbox_url to sandbox_url but this call site wasn't updated accordingly.

Fix in Cursor Fix in Web

)
token = config.access_token

if token is None:
Copy link
Member

Choose a reason for hiding this comment

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

I think this shouldn't be here, what if I use supabase headers for auth?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Improvement Improvement for current functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants