Skip to content

[eas-build-job][build-tools] Check Android launch inputs before the session starts - #4696

Merged
brentvatne merged 4 commits into
mainfrom
@brent/android-launch-arg-early-validation
Oct 20, 2026
Merged

brentvatne merged 4 commits into
mainfrom
@brent/android-launch-arg-early-validation

Conversation

@brentvatne

@brentvatne brentvatne commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Follows #4695 (merged), which added the Android shell quoting and the checks this PR moves earlier.

Why

On iOS, agent-device sessions validate launch inputs at the start of the step (validateServeSimLaunchOptions). On Android, launch inputs were only checked inside launchApplicationAsync, which runs after the emulator boots, the build downloads and the app installs. Input that can never work, such as a NUL character or a command too long for adb, therefore failed about a minute into a billed session.

Nothing in #4263 or #4324 says this was deliberate. #4324 made the up-front check iOS-only because it guards serve-sim's own limits, and Android never got an equivalent.

The check doesn't depend on the controller, so it belongs in @expo/eas-build-job. www can then run it when a session is created, for every session type and client, before any job starts.

How

  • @expo/eas-build-job now exports, from deviceRunSession.ts:
    • quoteAndroidShellCommand: the quoting from [build-tools] Quote Android launch arguments for the device shell #4695, plus the NUL and 65,000-byte checks. It measures bytes with TextEncoder, so it doesn't need Node's Buffer.
    • validateAndroidLaunchOptions({ launchArgs, openUrl }): runs those checks before the launch component (<package>/<activity>) is known. It measures the command without the component, so it rejects only commands that can never launch, and the launch still checks the exact command.
  • launchApplication.ts now uses quoteAndroidShellCommand from @expo/eas-build-job instead of its own copy. The launch still checks the exact command.
  • startAgentDeviceSession calls validateAndroidLaunchOptions next to the iOS check, so agent-device sessions fail before the emulator boots.
  • Follow-up in universe: once www's @expo/eas-build-job bump includes this, call validateAndroidLaunchOptions in validateApplicationLaunchOptions for Android sessions. That covers argent and Appium sessions too. They only receive launch inputs in the later eas/launch_application step, so until then they check at launch.

Test Plan

  • New tests in eas-build-job's deviceRunSession.test.ts:
    • quoting;
    • NUL rejection;
    • the length check, accepting a command of exactly 65,000 bytes without the component and rejecting one byte more;
    • byte counting, with a multibyte value at the limit. Counting characters instead fails this test;
    • the URL check.
  • New tests in startAgentDeviceSession.test.ts: a NUL argument, a NUL URL and an oversized command each fail before the emulator starts, the build downloads or the session starts. With the call removed, all three fail.
  • The full @expo/build-tools unit suite passes (2,438 tests), and so do yarn typecheck, yarn lint and yarn fmt:check.

🤖 Generated with Claude Code

@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.31%. Comparing base (53ac936) to head (8aabf49).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4696      +/-   ##
==========================================
+ Coverage   75.30%   75.31%   +0.01%     
==========================================
  Files        1053     1053              
  Lines       52170    52181      +11     
  Branches    11356    11398      +42     
==========================================
+ Hits        39281    39293      +12     
+ Misses      11901    11900       -1     
  Partials      988      988              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@brentvatne brentvatne changed the title [build-tools] Check Android launch inputs before the emulator boots [eas-build-job][build-tools] Check Android launch inputs before the session starts Oct 20, 2026
@brentvatne
brentvatne requested a review from gwdp October 20, 2026 04:27
Base automatically changed from @brent/android-launch-arg-quoting to main October 20, 2026 04:29
brentvatne and others added 4 commits October 19, 2026 21:29
Agent-device sessions checked Android launch inputs only when launching,
after the emulator booted and the build installed. Check NUL characters
and the command length at the start of the step, as on iOS, leaving room
for the launch component that is only known after install.
Move the Android shell quoting and the early launch input checks into
@expo/eas-build-job, so www can check launch inputs when a session is
created, for every session type.
…nd early

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@brentvatne
brentvatne force-pushed the @brent/android-launch-arg-early-validation branch from eb6d150 to 8aabf49 Compare October 20, 2026 04:30
@github-actions

Copy link
Copy Markdown

✅ Thank you for adding a changeset!

@gwdp gwdp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you!!

@brentvatne
brentvatne merged commit 9f674b1 into main Oct 20, 2026
10 checks passed
@brentvatne
brentvatne deleted the @brent/android-launch-arg-early-validation branch October 20, 2026 20:40
AndrewSouthpaw added a commit to AndrewSouthpaw/eas-cli that referenced this pull request Oct 22, 2026
…t-dirs

* upstream/main: (128 commits)
  [build-tools] stop logging workflow hook parsing in build logs (expo#4717)
  [build-tools] retry download_build network failures and report their cause (expo#4690)
  [eas-cli][build-tools] Bump Node.js to 22.23.4 (expo#4714)
  [eas-cli] make command descriptions lowercase without trailing periods (expo#4385)
  [build-tools] Add `max_duration_seconds` to sandboxes (expo#4702)
  [eas-cli] Show simulator session errors in simulator:get (expo#4694)
  [eas-cli] Show why a simulator session failed to start (expo#4693)
  [worker] Mask secrets in every field of uploaded log records (expo#4698)
  [eas-build-job][build-tools] Check Android launch inputs before the session starts (expo#4696)
  bump STAGING and PRODUCTION to 25.3.0 in cli-versions.json
  v25.3.0
  [eas-cli] Add --system-image to eas simulator:start (expo#4500)
  [build-tools] Wait up to five minutes for Google Play to process an uploaded bundle (expo#4700)
  [build-tools] Quote Android launch arguments for the device shell (expo#4695)
  [build-tools] Forward network capture through local egress (expo#4598)
  [build-tools] Let serve-sim start the iOS Simulator for Appium (expo#4603)
  [build-tools] Let serve-sim start the iOS Simulator for Argent (expo#4602)
  [build-tools] Upload iOS Simulator session screen recording metadata (expo#4689)
  [build-tools] Reset the session idle timer on serve-sim preview input (expo#4691)
  [eas-cli] Add a checkout prompt experiment to the Free plan build limit error (expo#4633)
  ...
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