Repository navigation
fix(adb): keep the device's refusal when a package change exits nonzero - #2344
Conversation
Current adb exits 1 when the device refuses an install or uninstall and prints the Failure [...] verdict to stderr or stdout. That run was reported as unreadable output with no details, so the refusal reason was only kept for the legacy zero-exit form. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
@greptileai review |
|
This PR is set for a Plus review. TREX isn't supported with Plus or Apex reviews yet, so Greptile reviews this PR at Base while TREX is on. |
|
Address review findings at their producing boundaries and preserve directly affected consumers. Source inspection and git diff --check completed. Tests and automated checks were not run at the user’s explicit request.
|
Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open. The refusal tests protected the message but omitted the public reason field. Both nonzero install and uninstall tests now assert the exact details.reason independently of the message, preserving the device verdict projection contract. Source inspection and git diff --check completed. Tests and automated checks were not run at the user’s explicit request. Commit: 355ff87 |
Summary
When a device refuses an install or uninstall, REA reports "unreadable output" and drops the device's reason.
install_adb_packageanduninstall_adb_packageonly keep theFailure [...]verdict when adb exits 0, which adb does not do for a refusal.No issue is linked: I found this while reading how adb failures are classified, and it is an ordinary fix inside the existing ADB provider.
Problem and expected behavior
Smallest trigger: any refused package change, for example installing a package that is already present.
adb exits nonzero for a refusal. On AOSP
android11-release:adb install:adb/client/adb_install.cppprintsadb: failed to install <file>: <status line>to stderr and returns 1 whenever the status line is notSuccess.adb uninstall: adb returns the status ofcmd package uninstall, andPackageManagerShellCommand.runUninstallprintsFailure [...]to stdout and returns 1.runAdbCaptureturns that nonzero exit into anAnalysisProtocolError, and both operations returned it before looking at the text:So
parsePackageChangeOutputonly ever saw zero-exit output. The existing tests cover that form (Failure [...]on stdout withexit 0), which is why this was not caught. docs/adb-device-analysis.md says installs "preserve the device'sFailure [...]reason verbatim"; for a nonzero exit they did not.Expected: the same
unsupported_targetrefusal carrying the device's reason, whichever exit status adb used.Change and scope
packageChangeFailureReason(output)insrc/adb/AdbShellOutput.tsis now the one reader of theFailure [REASON]syntax.parsePackageChangeOutputuses it, with unchanged results.packageChangeRefusal(...)insrc/adb/AdbProvider.tsreads the verdict from a failed run's captured stdout and stderr. Install and uninstall call it before returning the run's error.Failure [...]verdict is left exactly as it was, so transport and protocol failures are not relabelled as device refusals. Device-state errors (offline, unauthorized, not found) are still classified earlier byrunAdbCapture.Not included:
pull_adb_package's handling of a nonzeropm path, which open PR #1903 is already changing.Follow the contribution scope.
Scope decision: not applicable. No new capability; this only changes how an existing operation reports a refusal.
Contract and boundary impact
src/adb/AdbShellOutput.ts; the install and uninstall operations insrc/adb/AdbProvider.ts.unsupported_targetwithdetails.reasoninstead ofunreadable_outputwith no details.docs/public/product-catalog.json), package, or installation impact: none.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
The two operations already install and remove packages on the selected device; this PR does not change what they run.
Evidence and regression coverage
Tests added or updated: three cases in
src/adb/AdbProvider.test.tsusing the existing adb stub: a refused install reported on stderr with exit 1, a refused uninstall reported on stdout with exit 1, and a nonzero install with no verdict, which must stayunreadable_output.Base reproduction or other evidence (executed): without the fix the first two cases fail with
unreadable_outputwhereunsupported_targetis expected. The adb and Package Manager exit behavior is source-derived from the two AOSPandroid11-releasefiles linked above; I did not check other releases.User-visible CLI/MCP output (executed with
REA_ADB_PATHpointing at a stand-in adb that reports refusals as above):Before, on
fd95880, for both commands:{ "code": "unreadable_output", "message": "Analysis returned an unreadable result. Run `rea doctor` and review the reported details; repeating the unchanged request is not expected to succeed.", "details": null }After,
rea install-adb-package emulator-5554 app.apk:{ "code": "unsupported_target", "message": "Unsupported target for install_adb_package at emulator-5554: INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install com.example without first uninstalling.", "details": { "operation": "install_adb_package", "path": "emulator-5554", "reason": "INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install com.example without first uninstalling." } }After,
rea uninstall-adb-package emulator-5554 com.absent:{ "code": "unsupported_target", "message": "Unsupported target for uninstall_adb_package at emulator-5554: not installed for 0", "details": { "operation": "uninstall_adb_package", "path": "emulator-5554", "reason": "not installed for 0" } }Remaining proof gaps: not run against a real device or a real adb binary; the stand-in reproduces the stream and exit status that the AOSP sources describe.
For evidence-bearing changes:
Validation performed
macOS 15.6.1 arm64, Node 24.18.0, npm 11.16.0.
npm run test:local -- src/adb/AdbProvider.test.ts— 50 passednpx vitest run src/adb— 5 files, 106 tests passednpm run test:focused -- tests/boundary/cli/adbCli.test.ts tests/boundary/mcp/adbMcp.test.ts tests/boundary/mcp/adbStartMcp.test.ts tests/boundary/process/adbDirectoryListing.test.ts tests/boundary/providers/adb/adbBugreportPublication.test.ts— 5 files, 21 tests passednpm run check— passednpm run check:fast— passedNot run:
npm run check:pr,npm run docs:check(no contract or generated metadata changes), and no real-device lane.Compatibility, safety, and release
Before merge
type(scope): outcome.AI assistance (Claude Code, model Claude Opus 5.5) was used for investigation, implementation and running the tests locally.
🤖 Generated with Claude Code