Repository navigation
fix(adb): report the device state when a push cannot probe the path - #2354
Conversation
A push without overwrite read any unclassified failure of its existence probe as an existing path, so an offline or unauthorized device was reported as "the device path already exists". With overwrite it pushed after a probe that had not established anything. The probe's own refusal is now returned in both cases. 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. |
Review Finding & Error Type InvariantIn if (
!existsProbe.ok &&
!(existsProbe.error instanceof AnalysisProtocolError)
)
return existsProbe;
const deviceExists = existsProbe.ok;
if (deviceExists && !input.overwrite)
return err(
new AnalysisOutputError(
`Remote path ${input.device_path} already exists on device ${input.serial} and overwrite was not requested`,
),
);Finding: Error Typing on Target Collision
Suggested FixWrap the refusal in |
|
@matbrgz The refusal you quote is not part of this change, and the snippet differs from the code. On main it reads: new AnalysisOutputError(
operation,
`The device path already exists and overwrite was not requested: ${input.device_path}`,
)This diff does not touch it; it only changes what happens when the existence probe itself is refused. Two things on main depend on that error type today: the test "refuses a push onto an existing device path without overwrite" expects |
|
@huiq777 Thanks for the clarification! You are right that the downstream Looking strictly at the diff in this PR: if (
!existsProbe.ok &&
!(existsProbe.error instanceof AnalysisProtocolError)
)
return existsProbe;cleanly fixes the false "already exists" assertion when the device is offline, unauthorized, or failing to communicate, and returns the actual probe error ( The fix is focused, correct, and respects the scope of the problem. |
|
@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. |
|
Summary
push_adb_filetells the caller "the device path already exists" when the device is offline or unauthorized. Withoverwrite: trueit goes on to push even though its existence probe established nothing.No issue is linked: I found this while reading the push path, and it is an ordinary fix inside the existing ADB provider.
Problem and expected behavior
Before pushing, the provider runs
adb shell test -e <device_path>. The outcome was classified like this:Smallest trigger: the probe fails with
error: device offline(ordevice unauthorized, ordevice '…' not found).runAdbCaptureclassifies those asAnalysisUnsupportedTargetError, which lands in the last branch.overwrite: false(the default) the comment's push never runs. The caller getsunreadable_outputwith "The device path already exists and overwrite was not requested", which is false and suggests retrying withoverwrite: true.overwrite: truethe push does run, after a probe that did not determine whether the path exists, and a success would reportoverwritten: truewithout having observed that.Expected: existence is unknown, so the probe's own refusal is returned and nothing is pushed. This is what
inspect_adb_devicealready returns for the same stderr.Change and scope
The probe now has two understood outcomes and everything else is reported as is:
AnalysisProtocolError):test -esays the path is absent, unchanged;deviceExistsis then simplyexistsProbe.ok. Timeout, cancellation and resource failures were already returned this way; the device-state refusals now join them, which removes four branches.Not included: an unclassified nonzero probe exit that does carry stderr text is still read as "absent", as before. Tightening that to an empty-stderr exit 1 would be a separate decision.
Follow the contribution scope.
Scope decision: not applicable. This makes an existing mutation run in fewer cases.
Contract and boundary impact
src/adb/AdbProvider.ts.unsupported_targetwith adb's diagnosis instead of the "already exists"unreadable_output.overwrittenis now only ever reported from an observed probe result.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.
push_adb_filealready writes a file on the selected device; this PR only removes one case in which it did so.Evidence and regression coverage
Tests added or updated: a table test in
src/adb/AdbProvider.test.tsusing the existing adb stub, for an offline and an unauthorized device without overwrite and an offline device with overwrite. Each expectsunsupported_targetcarrying the device state, no "already exists" text, and exactly one adb device call (the probe), so no push ran.Base reproduction or other evidence (executed): without the fix all three rows fail. The two without overwrite return
unreadable_output; the one with overwrite records apushcall after the failed probe.User-visible CLI/MCP output (executed with
REA_ADB_PATHpointing at a stand-in adb that answers every device command witherror: device offline), forrea push-adb-file emulator-5554 payload.bin /data/local/tmp/payload.bin:Before, on
4dd44dd:{ "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": { "operation": "push_adb_file", "reason": "The device path already exists and overwrite was not requested: /data/local/tmp/payload.bin" } }After:
{ "code": "unsupported_target", "message": "Unsupported target for push_adb_file at /data/local/tmp/payload.bin: error: device offline", "details": { "operation": "push_adb_file", "path": "/data/local/tmp/payload.bin", "reason": "error: device offline" } }Remaining proof gaps: not run against a real device or a real adb binary.
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
overwrite: trueto a device adb refuses now gets the probe's refusal instead of the push's; both carry adb's diagnosis.This touches the same two files as #2344 in different places; whichever lands second may need a trivial rebase, which I will do.
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