fix(android): surface adb shell exit code in runAdbShell#2630
fix(android): surface adb shell exit code in runAdbShell#2630yuyutaotao wants to merge 1 commit into
Conversation
adb.shell only resolves with stdout, and on devices using the legacy adb shell protocol the remote command's exit code is not propagated to the adb process. A failing command therefore resolved as if it succeeded and callers could not perceive the failure. Add AndroidDevice.runShellCommandWithExitCode, which appends an exit-code marker to the command, parses it back from stdout, and throws (including stdout/stderr) when the command exits non-zero. Route both the action call and the timeout path of agent.runAdbShell through it so failures are observable across shell protocol versions. https://claude.ai/code/session_01L925LrXF9ungqFc1mXKyPi
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 12a84ccc0a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| debugDevice( | ||
| `runShellCommandWithExitCode: exit code marker not found for command: ${command}`, | ||
| ); | ||
| return stdout; |
There was a problem hiding this comment.
Throw when the exit marker is missing
When the user command terminates the shell before the appended echo can run, such as agent.runAdbShell('exit 1') or exec false, no marker is emitted. On the legacy adb shell protocol this is the exact case where the remote exit status is not propagated to the host, so returning raw stdout here still reports a failing command as successful instead of surfacing the failure.
Useful? React with 👍 / 👎.
adb.shell only resolves with stdout, and on devices using the legacy adb
shell protocol the remote command's exit code is not propagated to the
adb process. A failing command therefore resolved as if it succeeded and
callers could not perceive the failure.
Add AndroidDevice.runShellCommandWithExitCode, which appends an exit-code
marker to the command, parses it back from stdout, and throws (including
stdout/stderr) when the command exits non-zero. Route both the action
call and the timeout path of agent.runAdbShell through it so failures are
observable across shell protocol versions.
https://claude.ai/code/session_01L925LrXF9ungqFc1mXKyPi