fix(core): allow spaces in a launch argument name

Merged
OK
4d ago
+49-16

What

The object form of app.launchArguments accepts a name with spaces inside it:

app: { launchArguments: { 'NSSplitView Subview Frames Main': ['0, 0, 200, 600'] } }

A name with a control character, a space at either end, or whitespace other than a space still fails with INVALID_CONFIG.

Why

AppKit autosave names produce user-defaults keys with spaces, such as NSSplitView Subview Frames <name>. The object form refused any whitespace in a name, so such a key could only be written in the list form.

Neither https://github.com/e2e-inc/e2e/pull/1903 nor its review threads give a reason for the rule. I traced every consumer of the object form to see whether a space can split a name:

ConsumerHow the name travelsSafe
appleUserDefaults (core)-${name} as one array itemyes
desktop()Command::new("/usr/bin/open") ... .arg("--args").args(...), no shell (crates/e2e-desktop-napi/src/launch.rs:167)yes
mobile() iOS simulatoragent-device pushes the items onto the simctl launch argvyes
mobile() iOS deviceagent-device pushes them after -- on devicectl device process launchyes
mobile() Android['--es', name, value]; agent-device 0.21.43 single-quotes every adb shell word outside [A-Za-z0-9_@%+=:,./-]yes
Device providersnone read the names; they pass the same list the engine builds. The Revyl backend refuses launch arguments altogetheryes

The list form and object values ("a b", (fr, en-GB)) already carried spaces through every one of these paths, so a spaced name adds no new kind of input.

How it works

  1. checkLaunchArguments refuses a name with a control character or whitespace other than U+0020, then a name with a space at either end (packages/core/src/internal/launch-arguments.ts:45). Before, it refused any \s.
  2. A tab, a no-break space, or a space at either end stays refused because it is a typo the app would never read. The list form still takes any string.
  3. docs/reference/config.mdx and docs/reference/engine.mdx state the new rule.

Issue

From a teammate's findings report on the desktop engine; no GitHub issue. No Linear tool in this session, so the title carries no ticket id.

Verified

Ran it locally: yes

  • Desktop testbed in background mode, a scratch config that adds launchArguments: { 'NSSplitView Subview Frames Main': ['0, 0, 200, 600'], e2e: true } to the testbed target, and a test that opens the app and reads the launched process's argv through sysctl KERN_PROCARGS2.
mainthis PR
INVALID_CONFIG: target "macos" app.launchArguments argument name "NSSplitView Subview Frames Main" must have no whitespace or control characterstest passes, the key is one argument
argv: [".../build/SignInForm.app/Contents/MacOS/SignInForm","-ApplePersistenceIgnoreState","YES","-NSSplitView Subview Frames Main","(\"0, 0, 200, 600\")","-e2e","YES"]
 ✓ |macos| tests-scratch/args.e2e.ts > a launch argument name with spaces is one process argument 453ms
  • A Foundation binary run as ./p "-NSSplitView Subview Frames Main" '("0, 0, 200, 600")' reads the array back from UserDefaults.standard under that key, so NSUserDefaults parses a spaced name.
  • Not run on a device: the iOS and Android rows above come from reading agent-device 0.21.43, not from a simulator or emulator launch.
  • Self-review in a fresh context found one thing, now fixed: the first version also let a no-break space and other Unicode whitespace through inside a name.