fix(mobile): validate device.setPermission's name and state before the device call
Merged
KA
10d ago+64+64+01234567890123456789-8-8-0123456789
What and why
device.openApp({ permissions })checks permission names and states, butdevice.setPermissionsent them straight to agent-device, so'camra'failed asENGINE_FAILURE("settings permission requires a target: ...").setPermissionnow runs the same check first: a bad name (naming the nearest one), a bad state, or a missing state isINVALID_ARGUMENT, and no device command is sent.- The reference gets a Throws table for
setPermission.
Issue
Fixes #1603
Verified
Ran it locally: yes - built CLI on an iPhone 16 simulator (iOS 18.5), scratch target on com.apple.Preferences, plus pnpm --filter @e2e-dev/mobile run test and pnpm check.
| main | this branch | |
|---|---|---|
setPermission('camra', 'grant') | ENGINE_FAILURE: permission camra grant failed: settings permission requires a target: all|camera|... | INVALID_ARGUMENT: device.setPermission has unknown key "camra"; did you mean "camera"? |
setPermission('camera', 'allow') | ENGINE_FAILURE: ... Invalid permission state: allow. Use <grant|deny|reset> ... | INVALID_ARGUMENT: device.setPermission.camera must be one of grant, deny, reset, got "allow" |
setPermission('camera', 'reset') | passes | passes |
Checklist
- Changeset added (
pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only. - Breaking change: title carries
!, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md). - Docs updated in the same PR: the
docs/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it. - Contract change: emitted
.d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures. - Engine contract change (
e2e/engine): changesets fore2e,@e2e-dev/web, and@e2e-dev/mobile.