solari-e2b-compat 0.2.9__tar.gz → 0.2.11__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/.gitignore +7 -0
  2. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/COMPAT.md +3 -2
  3. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/PKG-INFO +1 -1
  4. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/pyproject.toml +1 -1
  5. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/solari_e2b/__init__.py +1 -1
  6. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/solari_e2b/_filesystem.py +12 -0
  7. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/solari_e2b/_git.py +53 -35
  8. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/solari_e2b/code_interpreter/__init__.py +6 -1
  9. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/LICENSE +0 -0
  10. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/LICENSE-E2B +0 -0
  11. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/NOTICE +0 -0
  12. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/README.md +0 -0
  13. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/solari_e2b/_box.py +0 -0
  14. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/solari_e2b/_commands.py +0 -0
  15. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/solari_e2b/_config.py +0 -0
  16. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/solari_e2b/_loop.py +0 -0
  17. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/solari_e2b/_redact.py +0 -0
  18. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/solari_e2b/_request.py +0 -0
  19. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/solari_e2b/_sandbox.py +0 -0
  20. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/solari_e2b/_sync.py +0 -0
  21. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/solari_e2b/_template.py +0 -0
  22. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/solari_e2b/_vendor_user.py +0 -0
  23. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/solari_e2b/_volume.py +0 -0
  24. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/solari_e2b/code_interpreter/charts.py +0 -0
  25. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/solari_e2b/code_interpreter/client.py +0 -0
  26. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/solari_e2b/code_interpreter/code_interpreter_async.py +0 -0
  27. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/solari_e2b/code_interpreter/code_interpreter_sync.py +0 -0
  28. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/solari_e2b/code_interpreter/constants.py +0 -0
  29. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/solari_e2b/code_interpreter/exceptions.py +0 -0
  30. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/solari_e2b/code_interpreter/models.py +0 -0
  31. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/solari_e2b/exceptions.py +0 -0
  32. {solari_e2b_compat-0.2.9 → solari_e2b_compat-0.2.11}/solari_e2b/models.py +0 -0
@@ -70,3 +70,10 @@ infra/terraform/snapshots-volumes/.build/
70
70
  # (ASIA... + X-Amz-Security-Token). Never commit. Also stale PHASE_* here makes
71
71
  # a bare re-run skip bake+verify and exit 0 with zero assertions.
72
72
  infra/.deploy-e2e/
73
+
74
+ # Local Cloud Hypervisor fork checkout (patch series lives in patches/cloud-hypervisor-v43)
75
+ third_party/cloud-hypervisor/
76
+
77
+ # Build outputs accidentally committed on perf branches (excluded by staging/bare-metal-int)
78
+ /host-agent/host-agent
79
+ /bench/step-park/microbench
@@ -54,7 +54,7 @@ and the differences that are specific to Python.
54
54
  | `fork(count=)` | DIFF, live | Checkpoint then `count` new sandboxes from it; the gateway will not delete a checkpoint while a copy is alive, so each copy carries the checkpoint id in a hidden metadata key (`e2b.forkSnapshot`, not shown in `info.metadata`; you cannot set it yourself) and the **last copy killed deletes it** (waiting up to ~40 s). A copy that is not killed (it expires on its idle timeout) keeps the checkpoint, which is billed snapshot storage: kill your copies. Returns a sandbox or an exception per copy. |
55
55
  | `get_host(port)` | NO | E2B returns the host synchronously; Solari mints preview URLs on the gateway. Use the extension `sbx.get_preview_url(port)` (returns `{'url': ..., 'token': ...}`). |
56
56
  | `upload_url`, `download_url` | OK | `user=` and `use_signature_expiration=`: NO (the gateway chooses the lifetime). `get_signature(...)` reproduces E2B's signature computation. |
57
- | `git` | OK | E2B's git helper (`clone`, `init`, `remote_add`, `remote_get`, `status`, `branches`, `create_branch`, `checkout_branch`, `delete_branch`, `add`, `commit`, `reset`, `restore`, `push`, `pull`, `set_config`, `get_config`, `dangerously_authenticate`, `configure_user`) run as `git` commands in the sandbox, with `GIT_TERMINAL_PROMPT=0`; credentials are never left in the stored remote. The sandbox image needs git. `Git` is the blocking class, `AsyncGit` the async one. |
57
+ | `git` | OK | E2B's git helper (`clone`, `init`, `remote_add`, `remote_get`, `status`, `branches`, `create_branch`, `checkout_branch`, `delete_branch`, `add`, `commit`, `reset`, `restore`, `push`, `pull`, `set_config`, `get_config`, `dangerously_authenticate`, `configure_user`) run as `git` commands in the sandbox, with `GIT_TERMINAL_PROMPT=0`; credentials are never left in the stored remote and never appear in a command line: they travel in the command's environment through a per-command credential helper (`dangerously_store_credentials=True` is the explicit opt-in to keep them in the URL); a branch or remote name that starts with `-` is refused. The sandbox image needs git. `Git` is the blocking class, `AsyncGit` the async one. |
58
58
  | `update_network`, `get_mcp_url`, `envd_api_url`, `envd_direct_url`, `connection_config` | NO | `get_mcp_token()` returns `None` (MCP cannot be enabled), `traffic_access_token` is `None`. |
59
59
  | `Volume` / `AsyncVolume` | DIFF | `create`, `connect`, `get_info(volume_id)`, `list()`, `destroy` and mounting work (Solari persistent volumes). Reading and writing a volume's files without a sandbox (`read_file`, `write_file`, `make_dir`, `exists`, `update_metadata`, `remove`, instance `get_info` / `list`) and `token`: NO; mount the volume and use `sandbox.files`. |
60
60
  | `Secret` / `AsyncSecret` | NO | On purpose: E2B substitutes a secret into outbound requests so sandbox code never sees it; Solari injects an account secret into the sandbox environment, so mapping one onto the other would expose the value. |
@@ -76,6 +76,7 @@ and the differences that are specific to Python.
76
76
  |---|---|---|
77
77
  | `read(path, format='text' \| 'bytes' \| 'stream')` | OK, live | Relative paths resolve against the guest's `$HOME` and every path is normalised (no `.`, `..` or doubled slashes; `files.list('.')` entries are `/home/user/x`, not `/home/user/./x`). `bytes` returns a `bytearray`. `stream` returns a reader with one chunk: async-iterable in the async API, a plain iterator of `bytes` in the blocking API. A missing file raises `FileNotFoundException`. |
78
78
  | `write(path, data)`, `write_files(entries)` | OK, live | `str`, `bytes` or a file-like object. Parent directories are created. `metadata=`: NO. `gzip`, `use_octet_stream`: how E2B encodes the HTTP upload; Solari writes over its control channel, so they change nothing (the file is the same). Likewise `read(gzip=, stream_idle_timeout=)`. |
79
+ | `write` over 32 MiB | One write is one frame on the control channel, so more than 32 MiB raises `InvalidArgumentException` before anything is sent. Get a signed URL with `sandbox.upload_url(path)` and PUT the bytes to it (E2B has no `files.upload`). |
79
80
  | `list(path, depth)`, `get_info` | OK, live | Every symlink (also a dangling one) is returned as itself: `type=FileType.SYMLINK`, `symlink_target`, `permissions` like `Lrwxrwxrwx`, and it is not descended into by `depth`. `owner` and `group` are filled in. One extra shell command per listing does this (it needs `/bin/sh`; without it the plain listing is used: links are followed, `owner` / `group` are empty, and a dangling link raises). |
80
81
  | `exists`, `make_dir`, `rename`, `remove` | OK, live | |
81
82
  | `watch_dir(path, on_event, recursive=)` | DIFF, live | `FilesystemEvent.name` is relative to the watched path. Solari reports creates as `write`. `include_entry=True` adds the entry (best effort: none when the path is already gone). `allow_network_mounts` has no effect (Solari's watcher has no such limit). A watch ends after `timeout` seconds (default 60; 0 disables); `on_exit(None)` is called once, whether it timed out or you called `stop()`. |
@@ -93,7 +94,7 @@ and the differences that are specific to Python.
93
94
  | `Result` formats | DIFF | `text`, `html`, `markdown`, `svg`, `png`, `jpeg`, `latex`, `json` (as given by the kernel), `chart`. `pdf`, `javascript`, `data` and `extra` are not produced. `chart` is E2B's class for its type (`LineChart`, `ScatterChart`, `BarChart`, `SuperChart`, ... in `solari_e2b.code_interpreter.charts`) and appears when the guest kernel extracts a structured chart (not for every figure). |
94
95
  | `envs=` per run | NO | |
95
96
  | `timeout=` | DIFF | Stops waiting and raises `TimeoutException`; the kernel keeps running the code. No default timeout (E2B's is 300 s). |
96
- | `create_code_context(cwd, language)` | OK, live | Python only. |
97
+ | `create_code_context(cwd, language)` | OK, live | Python only. A `cwd` that cannot be entered raises `InvalidArgumentException` (it used to leave the context in `$HOME` silently). |
97
98
  | `list_code_contexts`, `remove_code_context`, `restart_code_context` | DIFF, live | Solari cannot list or destroy kernels. `list` returns contexts created by this process; `remove` forgets the context (the kernel stays until the sandbox ends); `restart` clears the context's variables and working directory without restarting the process. |
98
99
  | Default template | DIFF | `code-interpreter-v2` is built into your org on first `Sandbox.create()` without a template: about 90 seconds (two timed builds on 2026-11-07 took 92 s and 95 s), billed as a template build, and two processes that both find it missing each start a build. `build_code_interpreter_template()` (async) / `build_code_interpreter_template_sync()` prebuild it. |
99
100
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: solari-e2b-compat
3
- Version: 0.2.9
3
+ Version: 0.2.11
4
4
  Summary: E2B-compatible Python interface (sandboxes and code interpreter) over Solari Sandboxes. Not affiliated with E2B.
5
5
  Project-URL: Homepage, https://getsolari.com
6
6
  Author: Solari
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "solari-e2b-compat"
7
- version = "0.2.9"
7
+ version = "0.2.11"
8
8
  description = "E2B-compatible Python interface (sandboxes and code interpreter) over Solari Sandboxes. Not affiliated with E2B."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -76,4 +76,4 @@ class _UnsupportedModule:
76
76
 
77
77
  client = _UnsupportedModule()
78
78
 
79
- __version__ = "0.2.9"
79
+ __version__ = "0.2.11"
@@ -8,6 +8,8 @@ import io
8
8
  from datetime import datetime, timezone
9
9
  from typing import Any, AsyncIterator, Callable, Dict, List, Optional, Union
10
10
 
11
+ from solari_core.handle import MAX_SINGLE_CALL_BYTES
12
+
11
13
  from ._box import Box, fire
12
14
  from ._request import bounded
13
15
  from .exceptions import FileNotFoundException, InvalidArgumentException, SolariCompatUnsupported
@@ -44,6 +46,13 @@ exit 0
44
46
  """
45
47
 
46
48
 
49
+ def too_large_message(n: int) -> str:
50
+ return (
51
+ f"file too large for one files.write call ({n} bytes, max {MAX_SINGLE_CALL_BYTES}): "
52
+ "get a signed URL with sandbox.upload_url(path) and PUT the bytes to it, or write the file in parts"
53
+ )
54
+
55
+
47
56
  class _Meta:
48
57
  """What the shell helper learned about one path."""
49
58
 
@@ -206,6 +215,9 @@ class AsyncFilesystem:
206
215
  _reject(user, "files.write", metadata)
207
216
  abs_ = await self._box.abs(path)
208
217
  raw = _to_bytes(data)
218
+ # Core's own message points at files.upload(), which the E2B API does not have; E2B callers have upload_url().
219
+ if len(raw) > MAX_SINGLE_CALL_BYTES:
220
+ raise InvalidArgumentException(too_large_message(len(raw)))
209
221
 
210
222
  async def _w(sb: Any) -> None:
211
223
  # E2B creates missing parent directories.
@@ -109,6 +109,33 @@ def with_credentials(url: str, username: Optional[str], password: Optional[str])
109
109
  return urlunparse(parsed._replace(netloc=f"{username}:{password}@{parsed.netloc}"))
110
110
 
111
111
 
112
+ # Inline git credential helper: answers ``get`` from the command's environment, ignores ``store``/``erase``, holds no secret.
113
+ GIT_CREDENTIAL_HELPER = '!f() { test "$1" = get && printf "username=%s\\npassword=%s\\n" "$SOLARI_GIT_USERNAME" "$SOLARI_GIT_PASSWORD"; }; f'
114
+
115
+
116
+ def credential_auth(url: str, username: str, password: str) -> Tuple[List[str], Dict[str, str]]:
117
+ """Credentials for ONE git command against an http(s) remote: ``(-c options, environment)``. The username and password
118
+ travel as environment variables of that command and git reads them back through the inline helper, so they are never in
119
+ the URL (not in argv, which any process in the sandbox can read from /proc/<pid>/cmdline, and not in ``.git/config``).
120
+ The helper is bound to the remote's origin, so git hands the password to no other host."""
121
+ for v in (username, password):
122
+ if any(ch in v for ch in "\r\n\0"):
123
+ raise InvalidArgumentException("Git credentials must not contain line breaks or NUL.")
124
+ with_credentials(url, username, password) # the same validation as before: http(s) only, both parts present
125
+ parsed = urlparse(url)
126
+ origin = f"{parsed.scheme}://{parsed.netloc.rsplit('@', 1)[-1]}"
127
+ if "=" in origin or any(ch.isspace() for ch in origin):
128
+ raise InvalidArgumentException(f"Invalid Git URL: {url}")
129
+ cfg = ["-c", "credential.helper=", "-c", f"credential.{origin}.helper={GIT_CREDENTIAL_HELPER}"]
130
+ return cfg, {"SOLARI_GIT_USERNAME": username, "SOLARI_GIT_PASSWORD": password}
131
+
132
+
133
+ def reject_option_like(what: str, value: Optional[str]) -> None:
134
+ """A branch or remote name that starts with "-" would be read by git as an option; git forbids such branch names anyway."""
135
+ if value is not None and value.startswith("-"):
136
+ raise InvalidArgumentException(f'Git {what} must not start with "-": {value!r}')
137
+
138
+
112
139
  def strip_credentials(url: str) -> str:
113
140
  parsed = urlparse(url)
114
141
  if parsed.scheme not in ("http", "https") or not (parsed.username or parsed.password):
@@ -272,7 +299,10 @@ class AsyncGit:
272
299
  async def _run(self, cmd: str, envs: Optional[Dict[str, str]], user: Optional[str], cwd: Optional[str], timeout: Optional[float], request_timeout: Optional[float]) -> Any:
273
300
  return await self._commands.run(cmd, envs={**DEFAULT_GIT_ENV, **(envs or {})}, user=user, cwd=cwd, timeout=timeout, request_timeout=request_timeout)
274
301
 
275
- async def _git(self, args: List[str], repo_path: Optional[str], envs=None, user=None, cwd=None, timeout=None, request_timeout=None) -> Any:
302
+ async def _git(self, args: List[str], repo_path: Optional[str], envs=None, user=None, cwd=None, timeout=None, request_timeout=None, auth: Optional[Tuple[List[str], Dict[str, str]]] = None) -> Any:
303
+ if auth:
304
+ args = list(auth[0]) + list(args)
305
+ envs = {**(envs or {}), **auth[1]}
276
306
  return await self._run(build_git_command(args, repo_path), envs, user, cwd, timeout, request_timeout)
277
307
 
278
308
  async def _remote_url(self, path: str, remote: str, *c: Any) -> str:
@@ -289,26 +319,9 @@ class AsyncGit:
289
319
  return remotes[0]
290
320
  raise InvalidArgumentException("Remote is required when using username/password and the repository has multiple remotes.")
291
321
 
292
- async def _with_remote_credentials(self, path: str, remote: str, username: str, password: str, c: Tuple[Any, ...], operation: Callable[[], Awaitable[Any]]) -> Any:
293
- """Run ``operation`` with the credentials in the remote URL, then put the original URL back (also on failure)."""
294
- original = await self._remote_url(path, remote, *c)
295
- await self._git(["remote", "set-url", remote, with_credentials(original, username, password)], path, *c)
296
- result: Any = None
297
- op_error: Optional[BaseException] = None
298
- try:
299
- result = await operation()
300
- except Exception as e: # noqa: BLE001
301
- op_error = e
302
- restore_error: Optional[BaseException] = None
303
- try:
304
- await self._git(["remote", "set-url", remote, original], path, *c)
305
- except Exception as e: # noqa: BLE001
306
- restore_error = e
307
- if op_error:
308
- raise op_error
309
- if restore_error:
310
- raise restore_error
311
- return result
322
+ async def _with_remote_credentials(self, path: str, remote: str, username: str, password: str, c: Tuple[Any, ...], operation: Callable[[Tuple[List[str], Dict[str, str]]], Awaitable[Any]]) -> Any:
323
+ """Run ``operation`` with the credentials on that one command (never in the remote URL; no ``remote set-url``)."""
324
+ return await operation(credential_auth(await self._remote_url(path, remote, *c), username, password))
312
325
 
313
326
  async def clone(
314
327
  self,
@@ -327,25 +340,23 @@ class AsyncGit:
327
340
  ) -> Any:
328
341
  if password and not username:
329
342
  raise InvalidArgumentException("Username is required when using a password or token for git clone.")
330
- clone_url = with_credentials(url, username, password) if username and password else url
331
- sanitized = strip_credentials(clone_url)
332
- should_strip = not dangerously_store_credentials and sanitized != clone_url
333
- repo_path = path if not should_strip else path or derive_repo_dir_from_url(url)
334
- if should_strip and not repo_path:
335
- raise InvalidArgumentException("A destination path is required when using credentials without storing them.")
336
- args = ["clone", clone_url]
343
+ reject_option_like("branch", branch)
344
+ # dangerously_store_credentials is the caller's explicit choice to keep the credentials in the remote URL (and so in argv and
345
+ # .git/config). Otherwise they go through the per-command credential helper and are never in the URL.
346
+ has_creds = bool(username and password)
347
+ auth = credential_auth(url, username, password) if has_creds and not dangerously_store_credentials else None # type: ignore[arg-type]
348
+ target = with_credentials(url, username, password) if has_creds and dangerously_store_credentials else url
349
+ args = ["clone"]
337
350
  if branch:
338
351
  args += ["--branch", branch, "--single-branch"]
339
352
  if depth:
340
353
  args += ["--depth", str(depth)]
354
+ # "--" ends the options: a "url" such as --upload-pack=cmd is then a (bad) repository, not an option.
355
+ args += ["--", target]
341
356
  if path:
342
357
  args.append(path)
343
- c = (envs, user, cwd, timeout, request_timeout)
344
358
  try:
345
- result = await self._git(args, None, *c)
346
- if should_strip and repo_path:
347
- await self._git(["remote", "set-url", "origin", sanitized], repo_path, *c)
348
- return result
359
+ return await self._git(args, None, envs, user, cwd, timeout, request_timeout, auth=auth)
349
360
  except CommandExitException as e:
350
361
  if is_auth_failure(e):
351
362
  raise GitAuthException(_auth_message("clone", bool(username) and not password)) from e
@@ -380,12 +391,15 @@ class AsyncGit:
380
391
  return parse_git_branches((await self._git(["branch", "--format=%(refname:short)\t%(HEAD)"], path, envs, user, cwd, timeout, request_timeout)).stdout)
381
392
 
382
393
  async def create_branch(self, path: str, branch: str, envs: Optional[Dict[str, str]] = None, user: Optional[str] = None, cwd: Optional[str] = None, timeout: Optional[float] = None, request_timeout: Optional[float] = None) -> Any:
394
+ reject_option_like("branch name", branch)
383
395
  return await self._git(["checkout", "-b", branch], path, envs, user, cwd, timeout, request_timeout)
384
396
 
385
397
  async def checkout_branch(self, path: str, branch: str, envs: Optional[Dict[str, str]] = None, user: Optional[str] = None, cwd: Optional[str] = None, timeout: Optional[float] = None, request_timeout: Optional[float] = None) -> Any:
398
+ reject_option_like("branch name", branch)
386
399
  return await self._git(["checkout", branch], path, envs, user, cwd, timeout, request_timeout)
387
400
 
388
401
  async def delete_branch(self, path: str, branch: str, force: bool = False, envs: Optional[Dict[str, str]] = None, user: Optional[str] = None, cwd: Optional[str] = None, timeout: Optional[float] = None, request_timeout: Optional[float] = None) -> Any:
402
+ reject_option_like("branch name", branch)
389
403
  return await self._git(["branch", "-D" if force else "-d", branch], path, envs, user, cwd, timeout, request_timeout)
390
404
 
391
405
  async def add(self, path: str, files: Optional[List[str]] = None, all: bool = True, envs: Optional[Dict[str, str]] = None, user: Optional[str] = None, cwd: Optional[str] = None, timeout: Optional[float] = None, request_timeout: Optional[float] = None) -> Any:
@@ -432,10 +446,12 @@ class AsyncGit:
432
446
  async def push(self, path: str, remote: Optional[str] = None, branch: Optional[str] = None, set_upstream: bool = True, username: Optional[str] = None, password: Optional[str] = None, envs: Optional[Dict[str, str]] = None, user: Optional[str] = None, cwd: Optional[str] = None, timeout: Optional[float] = None, request_timeout: Optional[float] = None) -> Any:
433
447
  if password and not username:
434
448
  raise InvalidArgumentException("Username is required when using a password or token for git push.")
449
+ reject_option_like("remote", remote)
450
+ reject_option_like("branch", branch)
435
451
  c = (envs, user, cwd, timeout, request_timeout)
436
452
  if username and password:
437
453
  name = await self._remote_name(path, remote, *c)
438
- return await self._with_remote_credentials(path, name, username, password, c, lambda: self._git(self._push_args(name, remote, branch, set_upstream), path, *c))
454
+ return await self._with_remote_credentials(path, name, username, password, c, lambda auth: self._git(self._push_args(name, remote, branch, set_upstream), path, *c, auth=auth))
439
455
  try:
440
456
  return await self._git(self._push_args(None, remote, branch, set_upstream), path, *c)
441
457
  except CommandExitException as e:
@@ -453,6 +469,8 @@ class AsyncGit:
453
469
  async def pull(self, path: str, remote: Optional[str] = None, branch: Optional[str] = None, username: Optional[str] = None, password: Optional[str] = None, envs: Optional[Dict[str, str]] = None, user: Optional[str] = None, cwd: Optional[str] = None, timeout: Optional[float] = None, request_timeout: Optional[float] = None) -> Any:
454
470
  if password and not username:
455
471
  raise InvalidArgumentException("Username is required when using a password or token for git pull.")
472
+ reject_option_like("remote", remote)
473
+ reject_option_like("branch", branch)
456
474
  c = (envs, user, cwd, timeout, request_timeout)
457
475
  if not remote and not branch:
458
476
  try:
@@ -463,7 +481,7 @@ class AsyncGit:
463
481
  raise GitUpstreamException(_upstream_message("pull"))
464
482
  if username and password:
465
483
  name = await self._remote_name(path, remote, *c)
466
- return await self._with_remote_credentials(path, name, username, password, c, lambda: self._git(self._pull_args(remote, branch, name), path, *c))
484
+ return await self._with_remote_credentials(path, name, username, password, c, lambda auth: self._git(self._pull_args(remote, branch, name), path, *c, auth=auth))
467
485
  try:
468
486
  return await self._git(self._pull_args(remote, branch), path, *c)
469
487
  except CommandExitException as e:
@@ -555,7 +555,12 @@ class AsyncSandbox(_AsyncBase):
555
555
  async def make() -> Context:
556
556
  cid = await self._box.on(lambda sb: sb.create_code_context("python"))
557
557
  if cwd:
558
- await self._box.on(lambda sb: sb.run_code(f"import os\nos.chdir({json.dumps(cwd)})\n", language="python", context_id=cid))
558
+ # run_code reports a failed chdir in ``error`` (it does not raise); without this check a bad cwd silently left the context in $HOME.
559
+ r = await self._box.on(lambda sb: sb.run_code(f"import os\nos.chdir({json.dumps(cwd)})\n", language="python", context_id=cid))
560
+ if r.error:
561
+ msg = r.error if isinstance(r.error, str) else getattr(r.error, "message", None) or getattr(r.error, "name", None) or str(r.error)
562
+ msg = ([ln for ln in str(msg).splitlines() if ln.strip()] or [str(msg)])[-1].strip() # a traceback: its last line names the error
563
+ raise InvalidArgumentException(f"create_code_context: cwd {json.dumps(cwd)} cannot be used: {msg}")
559
564
  ctx = Context(cid, "python", cwd or await self._box.home())
560
565
  _ctx_of(self.sandbox_id)[cid] = ctx
561
566
  return ctx