Skip to content

fix(session): local Android create when multiple devices unselected - #410

Merged
KazuCocoa merged 5 commits into
appium:mainfrom
Mochxd:fix/android-multi-device-guard
Jun 18, 2026
Merged

fix(session): local Android create when multiple devices unselected#410
KazuCocoa merged 5 commits into
appium:mainfrom
Mochxd:fix/android-multi-device-guard

Conversation

@Mochxd

@Mochxd Mochxd commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Local Android session create could silently bind to the wrong device when multiple emulators or USB devices were connected and the agent skipped select_device. iOS already had a guard on the create path; Android did not so adding validateAndroidDeviceSelection() and runs it from buildAndroidCapabilities() before session creation.
If more than one Android device is connected and there is no explicit target (select_device or appium:udid in capabilities), create fails with a clear error instead of picking an arbitrary device.

Changes

  • add validateAndroidDeviceSelection() in create-session.ts
  • make buildAndroidCapabilities() async and call validation on local create
  • add unit tests for single device, multiple devices, remote server skip, and explicit appium:udid

Comment thread src/tools/session/create-session.ts Outdated
Comment on lines 99 to 111

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of this validation logic, I assume:

  const selectedDeviceUdid =
    !isRemoteServer && selectedLocalDevice?.platform === 'android'
      ? selectedLocalDevice?.udid
      : undefined;

can be

  const givenCaps = {...configCaps, ...customCaps};
  const selectedDeviceUdid =
    !isRemoteServer && !givenCaps['appium:udid'] && selectedLocalDevice?.platform === 'android'
      ? selectedLocalDevice?.udid
      : undefined;

Possibly iOS also can be simplified like this

@KazuCocoa KazuCocoa changed the title fix(session): block local Android create when multiple devices unselected fix(session): local Android create when multiple devices unselected Jun 18, 2026
@KazuCocoa
KazuCocoa merged commit 9fb5bc3 into appium:main Jun 18, 2026
6 checks passed
github-actions Bot pushed a commit that referenced this pull request Jun 18, 2026
## [1.85.9](v1.85.8...v1.85.9) (2026-06-18)

### Bug Fixes

* **session:** local Android create when multiple devices unselected ([#410](#410)) ([9fb5bc3](9fb5bc3))
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.85.9 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants