Repository navigation
fix(sandbox): pass NetworkSpec to boxlite 0.9.5 BoxOptions (#797) - #813
Merged
0xKT merged 2 commits intoOct 3, 2026
Merged
Conversation
…AI#797) boxlite 0.9.5 replaced the string `network` and list `allow_net` fields on `BoxOptions` with `network: Optional[boxlite.NetworkSpec]`. Update `BoxliteExecutor._ensure_box` to pass `boxlite.NetworkSpec(mode="disabled")` when `allow_net=False` and `boxlite.NetworkSpec(mode="enabled", allow_net=...)` when `allow_net` is a domain allowlist. Fixes EverMind-AI#797
6 of 12 tasks
0xKT
approved these changes
Oct 3, 2026
Member
|
Merged, thanks @truecallerabreham! Since the boxlite 0.9.5 bump, |
LivXue
pushed a commit
that referenced
this pull request
Oct 12, 2026
Fixes #797 ### Problem `pyproject.toml` pins `boxlite==0.9.5`, where `boxlite.BoxOptions` replaced the separate string `network` and list `allow_net` keyword arguments with `network: Optional[boxlite.NetworkSpec]`: - Passing `allow_net=False` in `BoxliteExecutor._ensure_box` still sets `extra_kwargs["network"] = "none"`, raising `TypeError: argument 'network': 'str' object cannot be cast as 'NetworkSpec'` on sandbox start. - Passing a domain allowlist (`allow_net=["pypi.org", ...]`) still sets `extra_kwargs["allow_net"] = self._allow_net`, raising `TypeError: BoxOptions.__new__() got an unexpected keyword argument 'allow_net'`. ### Solution - Pass `extra_kwargs["network"] = boxlite.NetworkSpec(mode="disabled")` when `self._allow_net is False`. - Pass `extra_kwargs["network"] = boxlite.NetworkSpec(mode="enabled", allow_net=self._allow_net)` when `isinstance(self._allow_net, list)`. - Leave `network` unset when `self._allow_net is True`. ### Testing - Added `TestBoxliteEnsureBoxNetworkSpec` in `tests/test_sandbox_unit.py` covering `allow_net=False`, `allow_net=[...]`, and `allow_net=True`. - `pytest tests/test_sandbox_unit.py -k "TestBoxliteEnsureBoxNetworkSpec or TestBoxliteStartFailureCleanup"` (`6 passed`). - `ruff check` and `ruff format --check` pass. Co-authored-by: Abreham Melese <xvimelese@gmail.com> Co-authored-by: KT <74288668+0xKT@users.noreply.github.com>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #797
Problem
pyproject.tomlpinsboxlite==0.9.5, whereboxlite.BoxOptionsreplaced the separate stringnetworkand listallow_netkeyword arguments withnetwork: Optional[boxlite.NetworkSpec]:allow_net=FalseinBoxliteExecutor._ensure_boxstill setsextra_kwargs["network"] = "none", raisingTypeError: argument 'network': 'str' object cannot be cast as 'NetworkSpec'on sandbox start.allow_net=["pypi.org", ...]) still setsextra_kwargs["allow_net"] = self._allow_net, raisingTypeError: BoxOptions.__new__() got an unexpected keyword argument 'allow_net'.Solution
extra_kwargs["network"] = boxlite.NetworkSpec(mode="disabled")whenself._allow_net is False.extra_kwargs["network"] = boxlite.NetworkSpec(mode="enabled", allow_net=self._allow_net)whenisinstance(self._allow_net, list).networkunset whenself._allow_net is True.Testing
TestBoxliteEnsureBoxNetworkSpecintests/test_sandbox_unit.pycoveringallow_net=False,allow_net=[...], andallow_net=True.pytest tests/test_sandbox_unit.py -k "TestBoxliteEnsureBoxNetworkSpec or TestBoxliteStartFailureCleanup"(6 passed).ruff checkandruff format --checkpass.