-
Notifications
You must be signed in to change notification settings - Fork 169
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Hi, I am trying to enable the secure
mode on the code interpreter sandbox and I am observing the following response when I try to execute this snippet of code:
Input
from e2b_code_interpreter import Sandbox
sandbox = Sandbox(secure=True)
res = sandbox.run_code("print('Hello, World!')")
print(res.to_json())
Output
{"results": [], "logs": "{\"stdout\": [], \"stderr\": []}", "error": "{\"name\": \"TypeError\", \"value\": \"str expected, not int\", \"traceback\": \"---------------------------------------------------------------------------TypeError Traceback (most recent call last)Cell In[1], line 1\\n----> 1 os.environ.set_envs_for_execution({'code': 401, 'message': 'unauthorized access, please provide a valid access token or method signing if supported'})\\n 2 print('Hello, World!')\\nFile ~/.ipython/profile_default/startup/0001_envs.py:28, in E2BEnviron.set_envs_for_execution(self, update)\\n 23 return_values = {\\n 24 key: self[key] for key in set(self.keys()).intersection(update.keys())\\n 25 }\\n 26 keys_to_remove = set(update.keys()).difference(self.keys())\\n---> 28 self.update(update)\\n 30 self.return_values = return_values\\n 31 self.keys_to_remove = keys_to_remove\\nFile /usr/local/lib/python3.12/_collections_abc.py:982, in MutableMapping.update(self, other, **kwds)\\n 980 if isinstance(other, Mapping):\\n 981 for key in other:\\n--> 982 self[key] = other[key]\\n 983 elif hasattr(other, \\\"keys\\\"):\\n 984 for key in other.keys():\\nFile ~/.ipython/profile_default/startup/0001_envs.py:11, in E2BEnviron.__setitem__(self, key, value)\\n 10 def __setitem__(self, key, value):\\n---> 11 super().__setitem__(key, value)\\n 12 self.return_values.pop(key, None)\\n 13 self.keys_to_remove.discard(key)\\nFile /usr/local/lib/python3.12/os.py:719, in _Environ.__setitem__(self, key, value)\\n 717 def __setitem__(self, key, value):\\n 718 key = self.encodekey(key)\\n--> 719 value = self.encodevalue(value)\\n 720 putenv(key, value)\\n 721 self._data[key] = value\\nFile /usr/local/lib/python3.12/os.py:793, in _createenviron.<locals>.encode(value)\\n 791 def encode(value):\\n 792 if not isinstance(value, str):\\n--> 793 raise TypeError(\\\"str expected, not %s\\\" % type(value).__name__)\\n 794 return value.encode(encoding, 'surrogateescape')\\nTypeError: str expected, not int\"}"}
Here is the traceback for easier reading:
---------------------------------------------------------------------------TypeError Traceback (most recent call last)Cell In[1], line 1
----> 1 os.environ.set_envs_for_execution({'code': 401, 'message': 'unauthorized access, please provide a valid access token or method signing if supported'})
2 print('Hello, World!')
File ~/.ipython/profile_default/startup/0001_envs.py:28, in E2BEnviron.set_envs_for_execution(self, update)
23 return_values = {
24 key: self[key] for key in set(self.keys()).intersection(update.keys())
25 }
26 keys_to_remove = set(update.keys()).difference(self.keys())
---> 28 self.update(update)
30 self.return_values = return_values
31 self.keys_to_remove = keys_to_remove
File /usr/local/lib/python3.12/_collections_abc.py:982, in MutableMapping.update(self, other, **kwds)
980 if isinstance(other, Mapping):
981 for key in other:
--> 982 self[key] = other[key]
983 elif hasattr(other, \"keys\"):
984 for key in other.keys():
File ~/.ipython/profile_default/startup/0001_envs.py:11, in E2BEnviron.__setitem__(self, key, value)
10 def __setitem__(self, key, value):
---> 11 super().__setitem__(key, value)
12 self.return_values.pop(key, None)
13 self.keys_to_remove.discard(key)
File /usr/local/lib/python3.12/os.py:719, in _Environ.__setitem__(self, key, value)
717 def __setitem__(self, key, value):
718 key = self.encodekey(key)
--> 719 value = self.encodevalue(value)
720 putenv(key, value)
721 self._data[key] = value
File /usr/local/lib/python3.12/os.py:793, in _createenviron.<locals>.encode(value)
791 def encode(value):
792 if not isinstance(value, str):
--> 793 raise TypeError(\"str expected, not %s\" % type(value).__name__)
794 return value.encode(encoding, 'surrogateescape')
TypeError: str expected, not int"}
It looks like I am able to make a connection to the server but there is an error happening somewhere in the handling of the request. I did some light digging and one suspect looks like the fastapi server for this template opens a websocket connection to handle /execute
but does not pass along auth info.
Thanks in advance for looking into this. Any advice on how to handle would be appreciated
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working