Skip to content

Commit 4b01003

Browse files
committed
fix(ios): diagnose a runner that cannot install, instead of blaming the screen
A physical device that is not covered by the runner's provisioning profile fails to install the XCTest runner. Every runner-backed command then failed with 'the current screen is overwhelming the iOS accessibility capture' and advice to run screenshot instead — which fails identically, because it needs the same runner. The suggested remedy could never work and the stated cause was never observed. Classify the install failure and say what it is: the profile does not cover this device, register it with the signing team. It is deliberately not an infrastructure reason, because no retry registers a device. Matching anchors on the CoreDevice error code and the English framework strings; the installer prose around them is localized by macOS, so the real log arrived partly in Polish. The recycle-budget error also stops asserting a cause it never observed. It now points at the runner log first and offers the heavy-screen reading second, which is where it belongs — that case is real, it just is not the only one. Observed on an iPhone that could not be added to the signing account.
1 parent 4c1d62e commit 4b01003

3 files changed

Lines changed: 63 additions & 2 deletions

File tree

‎src/platforms/__tests__/boot-diagnostics.test.ts‎

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { test } from 'vitest';
22
import assert from 'node:assert/strict';
3-
import { bootFailureHint, classifyBootFailure } from '../boot-diagnostics.ts';
3+
import {
4+
bootFailureHint,
5+
classifyBootFailure,
6+
isInfrastructureBootFailureReason,
7+
} from '../boot-diagnostics.ts';
48
import { AppError } from '@agent-device/kernel/errors';
59

610
test('classifyBootFailure maps timeout errors', () => {
@@ -57,3 +61,41 @@ test('connect phase does not classify non-timeout errors as connect timeout', ()
5761
});
5862
assert.equal(reason, 'BOOT_COMMAND_FAILED');
5963
});
64+
65+
test('classifies a runner install blocked by provisioning, not as a connect timeout', () => {
66+
// Real xcodebuild output from an iPhone that was not in the signing account.
67+
// The installer prose around it is localized by macOS, so only the CoreDevice
68+
// error code and the English framework strings can be matched.
69+
const stderr = [
70+
'AgentDeviceRunnerUITests-Runner encountered an error (Failed to install or launch the test runner.',
71+
'(Underlying Error: Nie można zainstalować „AgentDeviceRunnerUITests-Runner”.',
72+
'Failed to install embedded profile for com.callstack.agentdevice.runner.uitests.xctrunner :',
73+
'0xe8008012 (This provisioning profile cannot be installed on this device.)))',
74+
'** TEST EXECUTE FAILED **',
75+
].join('\n');
76+
77+
const reason = classifyBootFailure({
78+
message: 'Runner did not accept connection (xcodebuild exited early)',
79+
stderr,
80+
context: { platform: 'ios', phase: 'connect' },
81+
});
82+
83+
assert.equal(reason, 'IOS_RUNNER_DEVICE_NOT_PROVISIONED');
84+
assert.match(bootFailureHint(reason), /provisioning profile does not cover it/);
85+
assert.match(bootFailureHint(reason), /Register the device/);
86+
});
87+
88+
test('a provisioning failure is not treated as retryable infrastructure', () => {
89+
// Retrying cannot register a device with a signing team.
90+
assert.equal(isInfrastructureBootFailureReason('IOS_RUNNER_DEVICE_NOT_PROVISIONED'), false);
91+
});
92+
93+
test('still classifies a genuine runner connect timeout as such', () => {
94+
assert.equal(
95+
classifyBootFailure({
96+
message: 'Runner did not accept connection',
97+
context: { platform: 'ios', phase: 'connect' },
98+
}),
99+
'IOS_RUNNER_CONNECT_TIMEOUT',
100+
);
101+
});

‎src/platforms/apple/core/runner/runner-recycle-ledger.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ export function buildRunnerRecycleBudgetExhaustedError(
9292
command: command.command,
9393
commandId: command.commandId,
9494
recovery: 'runner_recycle_budget_exhausted',
95-
hint: 'The current screen is overwhelming the iOS accessibility capture (usually heavy or animating content). The app session is preserved: run `screenshot` for visual truth and interact with coordinate commands, or navigate to another screen and retry. Re-running the same command immediately will likely wedge again.',
95+
// This path only knows that a restart was already spent, never why the
96+
// runner failed. Naming the heavy-screen case as the cause sent people
97+
// to change screens when the runner had in fact failed to install.
98+
hint: 'Check the runner log for the underlying failure before retrying — a provisioning or code-signing error there means the runner cannot install on this device, and no retry will help. If the runner is healthy, the current screen is likely too heavy or animating for accessibility capture: the app session is preserved, so run `screenshot` for visual truth and interact by coordinates, or navigate to another screen.',
9699
logPath: options.logPath,
97100
},
98101
);

‎src/platforms/boot-diagnostics.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { asAppError } from '@agent-device/kernel/errors';
33
export type BootFailureReason =
44
| 'IOS_BOOT_TIMEOUT'
55
| 'IOS_RUNNER_CONNECT_TIMEOUT'
6+
| 'IOS_RUNNER_DEVICE_NOT_PROVISIONED'
67
| 'IOS_TOOL_MISSING'
78
| 'ANDROID_BOOT_TIMEOUT'
89
| 'ADB_TRANSPORT_UNAVAILABLE'
@@ -71,6 +72,19 @@ export function classifyBootFailure(input: {
7172
.join('\n')
7273
.toLowerCase();
7374

75+
// Matched before the connect-timeout branch: a runner that could not be
76+
// installed also never accepts a connection, and the timeout reading would
77+
// send the user to look at the screen or the network instead of the signing
78+
// account. Anchored on the CoreDevice error code and the English framework
79+
// strings, because the surrounding installer prose is localized.
80+
if (
81+
platform === 'ios' &&
82+
(haystack.includes('0xe8008012') ||
83+
haystack.includes('provisioning profile') ||
84+
haystack.includes('embedded profile'))
85+
) {
86+
return 'IOS_RUNNER_DEVICE_NOT_PROVISIONED';
87+
}
7488
if (
7589
platform === 'ios' &&
7690
(haystack.includes('runner did not accept connection') ||
@@ -129,6 +143,8 @@ export function bootFailureHint(reason: BootFailureReason): string {
129143
return 'Retry simulator boot and inspect simctl bootstatus logs; in CI reduce parallel jobs or use a larger runner.';
130144
case 'IOS_RUNNER_CONNECT_TIMEOUT':
131145
return 'Retry runner startup, inspect xcodebuild logs, and verify simulator responsiveness before command execution.';
146+
case 'IOS_RUNNER_DEVICE_NOT_PROVISIONED':
147+
return 'The XCTest runner cannot be installed on this device: its provisioning profile does not cover it. Register the device with the signing team (Xcode > Settings > Accounts, or add its UDID to the provisioning profile) and retry. Retrying without that will keep failing.';
132148
case 'ANDROID_BOOT_TIMEOUT':
133149
return 'Retry emulator startup and verify sys.boot_completed reaches 1; consider increasing startup budget in CI.';
134150
case 'ADB_TRANSPORT_UNAVAILABLE':

0 commit comments

Comments
 (0)