Skip to content

Commit 898b93a

Browse files
committed
fix(platform): Guide administrators through Access health check recovery.
1 parent 40b0fba commit 898b93a

7 files changed

Lines changed: 193 additions & 24 deletions

File tree

‎docs/guide/self-hosted-platform.md‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,19 @@ You can correct the database URL if the initial connection failed. Once Void has
357357

358358
If installation reports **Default-Deny (error 1050)**, Cloudflare blocked the HTTP health check before it reached Void. This is separate from the API token used to deploy the Workers.
359359

360-
Ask your account administrator to permit access to this installation's service hostnames. For a testing platform intended to be publicly reachable, use a narrowly scoped Access exception for those hostnames, not an account-wide change. The installer checks the API, proxy, and dispatch endpoints; its runtime probe credential does not authenticate to Cloudflare Access. A browser login does not authenticate the CLI's requests either. Deployed app hostnames will also need appropriate access rules.
360+
For a test platform intended to be publicly reachable:
361+
362+
1. Select the account named in the error and open **Zero Trust → Access controls → Applications → Create new application**.
363+
2. Choose **Self-hosted**. When adding destinations, choose **Worker** and select the API, proxy, and dispatch Workers listed in the error.
364+
3. Add a policy with **Action → Bypass** and **Include → Everyone**.
365+
4. Save the policy and application, then run the resume command shown by Void.
366+
367+
This removes Cloudflare Access protection for those Workers, not just their health-check URLs. Void's own authentication remains enabled. Keep account-wide Default-Deny on. Deployed apps will also need appropriate access rules.
361368

362369
Once access is configured, rerun `void platform install --resume --name <id>`. You do not need to delete the installation or recreate its resources.
363370

371+
If your platform must remain Access-protected, **do not add a Bypass policy**. The installer does not yet support Access authentication for self-hosted platform health checks; a browser login or Cloudflare API token does not authenticate those requests. Keep the protection in place until that integration is supported.
372+
364373
### Repair missing resources
365374

366375
Preview what needs repair, then apply it:

‎packages/void/src/cli/output.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ import pc from 'picocolors';
33

44
export { pc };
55

6+
/** Keep recovery commands on the same CLI when using the local checkout launcher. */
7+
export function cliCommandName(): 'void' | 'void-dev' {
8+
const entryName = process.argv[1]?.split(/[\\/]/).at(-1);
9+
return entryName === 'void-dev' || entryName === 'void-dev.cmd' ? 'void-dev' : 'void';
10+
}
11+
612
/**
713
* CI-safe spinner wrapper. In CI environments (GitHub Actions, etc.),
814
* `@clack/prompts` spinner emits DEC Private Mode cursor hide/show codes

‎packages/void/src/cli/platform-installer.ts‎

Lines changed: 54 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -258,17 +258,8 @@ export type PlatformInstallerDependencies = Readonly<{
258258
manifest: PlatformInstallationManifest,
259259
databaseCheckpointExists: boolean,
260260
) => Promise<void>;
261-
verifyHealth?: (
262-
apiUrl: string,
263-
installationId: string,
264-
proxyUrl: string,
265-
applicationBaseDomain: string,
266-
platformVersion: string,
267-
usageProtocolVersion: 0 | 1,
268-
healthProbeToken: string,
269-
fetcher?: typeof fetch,
270-
dispatchOrigin?: string,
271-
) => Promise<void>;
261+
healthCheckResumeCommand?: string;
262+
verifyHealth?: typeof verifyPlatformHealth;
272263
verifySandboxDrain?: (apiUrl: string, healthProbeToken: string) => Promise<boolean>;
273264
verifyWorkerCutover?: (
274265
manifest: PlatformInstallationManifest,
@@ -1489,6 +1480,15 @@ export async function installPlatform(
14891480
manifest = transitionInstallation(manifest, 'verifying', now());
14901481
writeInstallationManifest(manifest);
14911482
dependencies.onProgress?.('Verifying platform health');
1483+
const healthCheckContext: PlatformHealthCheckContext = {
1484+
accountName: plan.account.name,
1485+
workers: [
1486+
plan.deployment.resources.apiWorker,
1487+
plan.deployment.resources.proxyWorker,
1488+
plan.deployment.resources.dispatchWorker,
1489+
],
1490+
resumeCommand: dependencies.healthCheckResumeCommand,
1491+
};
14921492
await (dependencies.verifyHealth ?? verifyPlatformHealth)(
14931493
plan.apiUrl,
14941494
manifest.id,
@@ -1501,6 +1501,7 @@ export async function installPlatform(
15011501
!plan.deployment.application.zoneName
15021502
? `https://${plan.deployment.resources.dispatchWorker}.${plan.workersSubdomain}.workers.dev`
15031503
: undefined,
1504+
healthCheckContext,
15041505
);
15051506
if (requiresSandboxDrain) {
15061507
const drainComplete = await (dependencies.verifySandboxDrain ?? verifyPlatformSandboxDrain)(
@@ -1742,6 +1743,7 @@ export async function installPlatform(
17421743
!plan.deployment.application.zoneName
17431744
? `https://${plan.deployment.resources.dispatchWorker}.${plan.workersSubdomain}.workers.dev`
17441745
: undefined,
1746+
healthCheckContext,
17451747
);
17461748
await verifyCurrentWorkerCutover();
17471749
}
@@ -4777,10 +4779,45 @@ function errorMessage(error: unknown): string {
47774779
return error instanceof Error ? error.message : String(error);
47784780
}
47794781

4782+
export type PlatformHealthCheckContext = Readonly<{
4783+
accountName: string;
4784+
workers: ReadonlyArray<string>;
4785+
resumeCommand?: string;
4786+
}>;
4787+
4788+
export class PlatformAccessBlockedError extends Error {
4789+
constructor(url: string, context?: PlatformHealthCheckContext) {
4790+
super(
4791+
[
4792+
'platform: Cloudflare Access blocked the platform health checks (Default-Deny, error 1050).',
4793+
`Blocked URL: ${url}`,
4794+
'',
4795+
'To make this test platform publicly reachable:',
4796+
'',
4797+
`1. In ${context ? `account ${JSON.stringify(context.accountName)}` : 'your Cloudflare account'}, open:`,
4798+
' Zero Trust → Access controls → Applications → Create new application.',
4799+
'2. Choose Self-hosted. When adding destinations, choose Worker and select:',
4800+
` ${context ? context.workers.join(', ') + '.' : "This installation's API, proxy, and dispatch Workers."}`,
4801+
'3. Add a policy: Action → Bypass; Include → Everyone.',
4802+
context?.resumeCommand
4803+
? `4. Save the policy and application, then resume:\n\n ${context.resumeCommand}`
4804+
: '4. Save the policy and application, then rerun your platform command.',
4805+
'',
4806+
'This removes Cloudflare Access protection for these Workers.',
4807+
'Void’s own authentication stays enabled. Keep account-wide Default-Deny on.',
4808+
'',
4809+
'For platforms that must remain Access-protected:',
4810+
'https://void.cloud/guide/self-hosted-platform#cloudflare-access',
4811+
].join('\n'),
4812+
);
4813+
}
4814+
}
4815+
47804816
async function platformProbeFailure(
47814817
label: string,
47824818
url: string,
47834819
response: Response,
4820+
context?: PlatformHealthCheckContext,
47844821
): Promise<Error> {
47854822
const message = `platform: ${label} failed at ${url} (HTTP ${response.status}).`;
47864823
if (
@@ -4790,9 +4827,7 @@ async function platformProbeFailure(
47904827
) {
47914828
const body = await response.text().catch(() => '');
47924829
if (body.includes('Default-Deny') && /errorCode:\s*1050\b/.test(body)) {
4793-
return new Error(
4794-
`${message} Cloudflare Access's account Default-Deny policy blocked the request before it reached Void (error 1050). Ask your account administrator to allow CLI access to this installation's service hostnames, then resume the installation. Signing in to Cloudflare in your browser does not authenticate these CLI health checks. See https://void.cloud/guide/self-hosted-platform#cloudflare-access.`,
4795-
);
4830+
return new PlatformAccessBlockedError(url, context);
47964831
}
47974832
}
47984833
return new Error(message);
@@ -4808,6 +4843,7 @@ export async function verifyPlatformHealth(
48084843
healthProbeToken: string,
48094844
fetcher: typeof fetch = fetch,
48104845
dispatchOrigin?: string,
4846+
context?: PlatformHealthCheckContext,
48114847
): Promise<void> {
48124848
const request = (url: string) =>
48134849
fetcher(url, {
@@ -4827,10 +4863,10 @@ export async function verifyPlatformHealth(
48274863
request(`${dispatchUrl}/health`),
48284864
]);
48294865
if (!health.ok) {
4830-
throw await platformProbeFailure('Health check', apiUrl, health);
4866+
throw await platformProbeFailure('Health check', apiUrl, health, context);
48314867
}
48324868
if (!discovery.ok) {
4833-
throw await platformProbeFailure('Discovery check', apiUrl, discovery);
4869+
throw await platformProbeFailure('Discovery check', apiUrl, discovery, context);
48344870
}
48354871
const body = (await discovery.json()) as {
48364872
installationId?: unknown;
@@ -4849,10 +4885,10 @@ export async function verifyPlatformHealth(
48494885
);
48504886
}
48514887
if (!proxy.ok) {
4852-
throw await platformProbeFailure('Proxy health check', proxyUrl, proxy);
4888+
throw await platformProbeFailure('Proxy health check', proxyUrl, proxy, context);
48534889
}
48544890
if (!dispatch.ok) {
4855-
throw await platformProbeFailure('Dispatch health check', dispatchUrl, dispatch);
4891+
throw await platformProbeFailure('Dispatch health check', dispatchUrl, dispatch, context);
48564892
}
48574893
}
48584894

‎packages/void/src/cli/platform-lifecycle.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
normalizeInstallationSlug,
55
type PlatformInstallationManifest,
66
} from '@void/platform';
7-
import { cliTitle, createSpinner, pc } from './output.ts';
7+
import { cliCommandName, cliTitle, createSpinner, pc } from './output.ts';
88
import type { PlatformArgs } from './platform-args.ts';
99
import {
1010
assertPlatformOperatorCredentialCanApplyPlan,
@@ -22,6 +22,7 @@ import {
2222
createPlatformInstallationSecrets,
2323
installPlatform,
2424
loadPlatformRuntime,
25+
PlatformAccessBlockedError,
2526
readPlatformDatabaseLifecycleManifest,
2627
resolveBootstrapGitHubId,
2728
} from './platform-installer.ts';
@@ -687,6 +688,7 @@ export async function runPlatformLifecycleCommand(args: PlatformArgs): Promise<v
687688
acquireDatabaseLifecycleLock: acquirePlatformDatabaseLifecycleLock,
688689
client,
689690
runtime,
691+
healthCheckResumeCommand: `${cliCommandName()} platform install --resume --name ${existing.id}`,
690692
onProgress: (message) => progress?.message(message),
691693
replanWorkers: async (manifest) =>
692694
(
@@ -748,8 +750,10 @@ export async function runPlatformLifecycleCommand(args: PlatformArgs): Promise<v
748750
} catch (error) {
749751
progress?.error('Platform installation failed.');
750752
progress = undefined;
751-
if (existing && !args.plan) {
752-
log.info('Continue with: void platform install --resume --name ' + existing.id);
753+
if (existing && !args.plan && !(error instanceof PlatformAccessBlockedError)) {
754+
log.info(
755+
`Continue with: ${cliCommandName()} platform install --resume --name ${existing.id}`,
756+
);
753757
}
754758
throw error;
755759
} finally {
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { afterEach, expect, it, vi } from 'vite-plus/test';
2+
import { cliCommandName } from '../../src/cli/output.ts';
3+
import { PlatformAccessBlockedError } from '../../src/cli/platform-installer.ts';
4+
5+
afterEach(() => vi.unstubAllGlobals());
6+
7+
it.each([
8+
['/usr/local/bin/void-dev', 'void-dev'],
9+
['C:\\tools\\void-dev.cmd', 'void-dev'],
10+
['/usr/local/bin/void', 'void'],
11+
['/checkout/packages/void/dist/cli/cli.mjs', 'void'],
12+
['/tmp/untrusted-command', 'void'],
13+
[undefined, 'void'],
14+
])('recognizes the CLI entry %s in recovery commands', (entry, expected) => {
15+
vi.stubGlobal('process', { ...process, argv: [process.execPath, entry] });
16+
expect(cliCommandName()).toBe(expected);
17+
});
18+
19+
it('shows the agreed dashboard instructions with the real installation details', () => {
20+
const error = new PlatformAccessBlockedError('https://api.example.workers.dev', {
21+
accountName: 'Example account',
22+
workers: ['void-example-api', 'void-example-proxy', 'void-example-dispatch'],
23+
resumeCommand: 'void-dev platform install --resume --name example-123',
24+
});
25+
expect(error.message)
26+
.toBe(`platform: Cloudflare Access blocked the platform health checks (Default-Deny, error 1050).
27+
Blocked URL: https://api.example.workers.dev
28+
29+
To make this test platform publicly reachable:
30+
31+
1. In account "Example account", open:
32+
Zero Trust → Access controls → Applications → Create new application.
33+
2. Choose Self-hosted. When adding destinations, choose Worker and select:
34+
void-example-api, void-example-proxy, void-example-dispatch.
35+
3. Add a policy: Action → Bypass; Include → Everyone.
36+
4. Save the policy and application, then resume:
37+
38+
void-dev platform install --resume --name example-123
39+
40+
This removes Cloudflare Access protection for these Workers.
41+
Void’s own authentication stays enabled. Keep account-wide Default-Deny on.
42+
43+
For platforms that must remain Access-protected:
44+
https://void.cloud/guide/self-hosted-platform#cloudflare-access`);
45+
});
46+
47+
it('does not tell upgrades or repairs to restart installation', () => {
48+
const error = new PlatformAccessBlockedError('https://api.example.com', {
49+
accountName: 'Example account',
50+
workers: ['original-api', 'original-proxy', 'original-dispatch'],
51+
});
52+
expect(error.message).toContain('rerun your platform command');
53+
expect(error.message).not.toContain('platform install');
54+
expect(error.message).toContain('original-api, original-proxy, original-dispatch');
55+
});
56+
57+
it('does not invent resource names when no installation context is available', () => {
58+
const error = new PlatformAccessBlockedError('https://api.example.com');
59+
expect(error.message).toContain('In your Cloudflare account');
60+
expect(error.message).toContain("This installation's API, proxy, and dispatch Workers.");
61+
expect(error.message).not.toContain('undefined');
62+
});

‎packages/void/test/unit/platform-installer.test.ts‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,20 @@ describe('platform installer', () => {
260260
_token,
261261
_fetcher,
262262
dispatchOrigin,
263+
context,
263264
) => {
264265
expect(dispatchOrigin).toBe(
265266
`https://${plan.deployment.resources.dispatchWorker}.workers-subdomain.workers.dev`,
266267
);
268+
expect(context).toEqual({
269+
accountName: plan.account.name,
270+
workers: [
271+
plan.deployment.resources.apiWorker,
272+
plan.deployment.resources.proxyWorker,
273+
plan.deployment.resources.dispatchWorker,
274+
],
275+
resumeCommand: undefined,
276+
});
267277
},
268278
});
269279
expect(result.manifest.status).toBe('installed');
@@ -1214,14 +1224,21 @@ describe('platform installer', () => {
12141224
'probe-token',
12151225
fetcher,
12161226
'https://void-example-dispatch.account.workers.dev',
1227+
{
1228+
accountName: 'Example account',
1229+
workers: ['legacy-api-123', 'custom-proxy', 'custom-dispatch'],
1230+
resumeCommand: 'void-dev platform install --resume --name example-a1b2c3d4',
1231+
},
12171232
).catch((error: unknown) => error);
12181233

12191234
expect(failure).toBeInstanceOf(Error);
12201235
const message = String(failure);
12211236
expect(message).toContain(new URL(blockedUrl).origin);
1222-
expect(message).toContain('Default-Deny policy blocked the request before it reached Void');
1237+
expect(message).toContain('Cloudflare Access blocked the platform health checks');
12231238
expect(message).toContain('error 1050');
1224-
expect(message).toContain('resume the installation');
1239+
expect(message).toContain('account "Example account"');
1240+
expect(message).toContain('legacy-api-123, custom-proxy, custom-dispatch');
1241+
expect(message).toContain('void-dev platform install --resume --name example-a1b2c3d4');
12251242
expect(message).not.toContain('untrusted-response-content');
12261243
expect(message).not.toContain('probe-token');
12271244
expect(message).not.toContain('https://test.account.workers.dev');

‎packages/void/test/unit/platform-setup-flow.test.ts‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
PlatformCloudflareApiError,
1010
PlatformCloudflareClient,
1111
} from '../../src/cli/platform-cloudflare.ts';
12+
import { PlatformAccessBlockedError } from '../../src/cli/platform-installer.ts';
1213
import { runPlatformLifecycleCommand } from '../../src/cli/platform-lifecycle.ts';
1314
import {
1415
listInstallationManifests,
@@ -397,6 +398,40 @@ describe('platform credential onboarding', () => {
397398
);
398399
});
399400

401+
it.each(['void', 'void-dev'])(
402+
'includes a %s resume command without a duplicate recovery hint',
403+
async (command) => {
404+
const originalArgv = process.argv;
405+
const info = vi.spyOn(log, 'info').mockImplementation(() => {});
406+
process.argv = [process.execPath, `/usr/local/bin/${command}`, ...args];
407+
try {
408+
mocks.install.mockImplementationOnce(async (plan, _secrets, manifest, dependencies) => {
409+
expect(dependencies.healthCheckResumeCommand).toBe(
410+
`${command} platform install --resume --name ${manifest.id}`,
411+
);
412+
throw new PlatformAccessBlockedError(plan.apiUrl, {
413+
accountName: plan.account.name,
414+
workers: [
415+
plan.deployment.resources.apiWorker,
416+
plan.deployment.resources.proxyWorker,
417+
plan.deployment.resources.dispatchWorker,
418+
],
419+
resumeCommand: dependencies.healthCheckResumeCommand,
420+
});
421+
});
422+
await expect(runPlatformLifecycleCommand(parsePlatformArgs(args))).rejects.toThrow(
423+
`${command} platform install --resume --name test-setup-123456abcdef`,
424+
);
425+
expect(mocks.progress.error).toHaveBeenCalledWith('Platform installation failed.');
426+
expect(info.mock.calls.some(([message]) => message.startsWith('Continue with:'))).toBe(
427+
false,
428+
);
429+
} finally {
430+
process.argv = originalArgv;
431+
}
432+
},
433+
);
434+
400435
it.each(['waitingForDns', 'waitingForSandboxDrain'] as const)(
401436
'stops progress when installation pauses for %s',
402437
async (reason) => {

0 commit comments

Comments
 (0)