fix: normalize shipyard shell exec response#8850
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the ShipyardShellWrapper execution logic to correctly unwrap nested execution responses where shell output is stored under the data field. It also adds a unit test to verify this behavior. The review feedback suggests simplifying the fallback logic for extracting stdout and stderr to make it more concise and idiomatic.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="tests/unit/test_computer.py" line_range="401-405" />
<code_context>
+ }
+ )
+
+ result = await ShipyardShellWrapper(raw_shell).exec(
+ "echo hello_from_shipyard_bay && pwd"
+ )
+
+ assert result == {
+ "stdout": "hello_from_shipyard_bay\n/workspace\n",
+ "stderr": "",
</code_context>
<issue_to_address>
**suggestion (testing):** Consider adding a complementary test for non-wrapped (legacy) exec responses to guard backward compatibility
Since this test only covers the nested `data` response from Shipyard Bay, please also add a sibling test where `raw_shell.exec` returns a flat payload (top-level `stdout`, `stderr`, `exit_code` and no `data` key). That will explicitly cover the legacy shape and reduce the risk of regressions in future changes to the unwrapping logic.
Suggested implementation:
```python
result = await ShipyardShellWrapper(raw_shell).exec(
"echo hello_from_shipyard_bay && pwd"
)
async def test_shipyard_shell_wrapper_exec_legacy_flat_response(self, raw_shell):
raw_shell.exec.return_value = {
"stdout": "hello_from_legacy_shell\n/workspace\n",
"stderr": "",
"exit_code": 0,
"pid": 16,
"process_id": None,
"error": None,
}
result = await ShipyardShellWrapper(raw_shell).exec(
"echo hello_from_legacy_shell && pwd"
)
assert result == {
"stdout": "hello_from_legacy_shell\n/workspace\n",
"stderr": "",
"exit_code": 0,
"pid": 16,
"process_id": None,
"error": None,
}
```
I assumed this code is inside a test class that already has access to a `raw_shell` fixture and `ShipyardShellWrapper` import, mirroring the existing Shipyard Bay response test. If the tests are function-based rather than class-based, drop the `self` parameter and remove the `self` qualifier from the new test definition:
```python
async def test_shipyard_shell_wrapper_exec_legacy_flat_response(raw_shell):
...
```
Also, if your project uses a specific async test framework marker (e.g. `pytest.mark.anyio` or `pytest.mark.asyncio`) applied at the class or module level, ensure the new test is covered by that same marker so it runs correctly.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
修复旧版 Shipyard Bay shell 命令实际执行成功,但 AstrBot 返回空
stdout、空stderr、exit_code: null的问题。旧版 Shipyard
/ship/{ship_id}/execAPI 会把 shell 执行结果包在data字段中,例如data.stdout、data.stderr、data.return_code。此前 AstrBot 只读取外层字段,导致命令输出和退出码被丢弃。Modifications / 改动点
更新
astrbot/core/computer/booters/shipyard.py,兼容 Shipyard Baysuccess/data/error包装结构。将
data.stdout/data.stderr正确映射为 AstrBot shell 工具输出。将
data.return_code正确映射为 AstrBotexit_code。在
tests/unit/test_computer.py中增加基于真实 Shipyard Bay 响应结构的回归测试。This is NOT a breaking change. / 这不是一个破坏性变更。
Screenshots or Test Results / 运行截图或测试结果
Checklist / 检查清单
😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
/ 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。
👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
/ 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。
🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in
requirements.txtandpyproject.toml./ 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到
requirements.txt和pyproject.toml文件相应位置。😮 My changes do not introduce malicious code.
/ 我的更改没有引入恶意代码。
Summary by Sourcery
Normalize handling of Shipyard Bay shell exec responses so shell command output and exit codes are correctly surfaced by AstrBot.
Bug Fixes:
Tests: