{"record":{"id":"f517667ffdd02ad5","repo":"agentscope-ai/agentscope","slug":"bubblewrap-write-failed-exit-result-exit-code","errorCode":null,"errorMessage":"Bubblewrap write failed (exit {result.exit_code}): {result.stderr.decode(errors='replace')}","messagePattern":"Bubblewrap write failed \\(exit (.+?)\\): (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/agentscope/workspace/_bubblewrap/_bubblewrap_backend.py","lineNumber":328,"sourceCode":"                    \"/workspace|/workspace/*|/tmp|/tmp/*) ;; \"\n                    \"*) exit 65 ;; \"\n                    \"esac; \"\n                    'mkdir -p -- \"$resolved_parent\" && '\n                    'target=\"$resolved_parent/$(basename -- \"$1\")\" && '\n                    '[ ! -L \"$target\" ] || exit 65; '\n                    'cat > \"$target\"'\n                ),\n                \"sh\",\n                sandbox_path,\n            ],\n            data,\n        )\n        if result.exit_code == 65:\n            raise PermissionError(\n                f\"path escapes writable Bubblewrap mounts: {path}\",\n            )\n        if not result.ok():\n            raise RuntimeError(\n                \"Bubblewrap write failed \"\n                f\"(exit {result.exit_code}): \"\n                f\"{result.stderr.decode(errors='replace')}\",\n            )\n\n    async def _exec_with_input(\n        self,\n        command: list[str],\n        data: bytes | AsyncIterator[bytes],\n        *,\n        cwd: str | None = None,\n        timeout: float | None = None,\n    ) -> ExecResult:\n        \"\"\"Run a sandbox command with ``data`` piped to stdin.\n\n        An async iterator is fed chunk by chunk, so a large payload\n        never materializes. Safe only because the commands run this way\n        write nothing to stdout — otherwise a full pipe would deadlock","sourceCodeStart":310,"sourceCodeEnd":346,"githubUrl":"https://github.com/agentscope-ai/agentscope/blob/e90f1c7592896cc95f6e5ee506194f533378247d/src/agentscope/workspace/_bubblewrap/_bubblewrap_backend.py#L310-L346","documentation":"Generic RuntimeError raised by _write_via_cat when the sandboxed write command fails with an exit code other than 65. The message contains the exit status and decoded stderr of the sandboxed process, which usually pinpoints disk, permission, or bwrap launch problems.","triggerScenarios":"Destination directory missing inside the sandbox, disk full, file exists as a directory, or bwrap failing to start the shell.","commonSituations":"Writing into a subdirectory never created in the sandbox, ENOSPC on the host backing the workdir bind mount, or a damaged bwrap runtime.","solutions":["Create parent directories inside the sandbox before writing","Check the embedded stderr and host disk space (df -h on the workdir)","Ensure the target path is not an existing directory","Re-run bwrap manually to confirm the runtime is healthy"],"exampleFix":"# before\nawait ws.write_file('/workspace/a/b/c.txt', data)  # a/b missing\n# after\nawait ws.run_command('mkdir -p /workspace/a/b')\nawait ws.write_file('/workspace/a/b/c.txt', data)","handlingStrategy":"fallback","validationCode":"await ws.run_command(f'mkdir -p {posixpath.dirname(sandbox_path)}')  # before write","typeGuard":"null","tryCatchPattern":"try:\n    await ws.write_file(p, data)\nexcept RuntimeError as e:\n    log.error('write failed: %s', e); raise","preventionTips":["Create parent directories before writes","Monitor disk space on the host workdir backing store"],"tags":["bubblewrap","write","io","runtime"],"backgroundTag":"sandbox-command-failed","analyzedSha":"e90f1c7592896cc95f6e5ee506194f533378247d","analyzedAt":"2026-08-28T18:24:12.087Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}