Skip to content

fix(android): surface adb shell exit code in runAdbShell#2630

Open
yuyutaotao wants to merge 1 commit into
mainfrom
claude/android-adb-exit-code-3o0uc7
Open

fix(android): surface adb shell exit code in runAdbShell#2630
yuyutaotao wants to merge 1 commit into
mainfrom
claude/android-adb-exit-code-3o0uc7

Conversation

@yuyutaotao

Copy link
Copy Markdown
Collaborator

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

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants