{"record":{"id":"3a96f30e6d4cd0ea","repo":"FoundationAgents/OpenManus","slug":"failed-to-create-sandbox-e-3a96f3","errorCode":null,"errorMessage":"Failed to create sandbox: {e}","messagePattern":"Failed to create sandbox: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"app/sandbox/core/sandbox.py","lineNumber":103,"sourceCode":"            self.container = self.client.containers.get(container[\"Id\"])\n\n            # Start container\n            await asyncio.to_thread(self.container.start)\n\n            # Initialize terminal\n            self.terminal = AsyncDockerizedTerminal(\n                container[\"Id\"],\n                self.config.work_dir,\n                env_vars={\"PYTHONUNBUFFERED\": \"1\"}\n                # Ensure Python output is not buffered\n            )\n            await self.terminal.init()\n\n            return self\n\n        except Exception as e:\n            await self.cleanup()  # Ensure resources are cleaned up\n            raise RuntimeError(f\"Failed to create sandbox: {e}\") from e\n\n    def _prepare_volume_bindings(self) -> Dict[str, Dict[str, str]]:\n        \"\"\"Prepares volume binding configuration.\n\n        Returns:\n            Volume binding configuration dictionary.\n        \"\"\"\n        bindings = {}\n\n        # Create and add working directory mapping\n        work_dir = self._ensure_host_dir(self.config.work_dir)\n        bindings[work_dir] = {\"bind\": self.config.work_dir, \"mode\": \"rw\"}\n\n        # Add custom volume bindings\n        for host_path, container_path in self.volume_bindings.items():\n            bindings[host_path] = {\"bind\": container_path, \"mode\": \"rw\"}\n\n        return bindings","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/FoundationAgents/OpenManus/blob/52a13f2a57d8c7f6737eefb02ccf569594d44273/app/sandbox/core/sandbox.py#L85-L121","documentation":"Raised by DockerSandbox.create (app/sandbox/core/sandbox.py:103) when any step of sandbox bring-up throws: container creation, volume binding preparation, or AsyncDockerizedTerminal init. On failure it awaits self.cleanup() to release the half-created container, then raises RuntimeError chained (`from e`) to the original exception. This is the inner exception that manager.create_sandbox wraps into error 23.","triggerScenarios":"Container start fails due to invalid config (bad image, conflicting volume binds, unsupported options); container['Id'] fetch succeeds but exec session for the terminal fails; cleanup path itself errors; work_dir host dir cannot be created (permissions).","commonSituations":"Non-writable host path for the work_dir volume; image lacks /bin/sh so exec fails; Docker API version mismatch between client library and daemon; SELinux/AppArmor denying the bind mount.","solutions":["Look at __cause__ of this RuntimeError — it is the original docker/terminal error.","Test the same container manually: docker run -v <workdir>:<workdir> <image> sh.","Ensure the host work_dir exists and is writable; ensure the image has a shell.","Match docker library API version to the daemon (DowngradeAPI/upgrade issues)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    sandbox = await DockerSandbox(config).create()\nexcept RuntimeError as e:\n    cause = e.__cause__  # original docker / terminal error\n    log.error(\"create failed: %r\", cause)\n    raise","preventionTips":["Test the image manually with the same volume flags","Ensure host work_dir is writable and the image has a shell","Keep the docker library API version compatible with the daemon","Never reuse a sandbox object after create() raised — cleanup already ran"],"tags":["docker","sandbox","lifecycle","terminal","chained-exception"],"backgroundTag":null,"analyzedSha":"52a13f2a57d8c7f6737eefb02ccf569594d44273","analyzedAt":"2026-08-15T02:33:49.993Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}