Skip to content

Commit 9982846

Browse files
matej21claude
andcommitted
fix: validate accountId and apiToken before deploy
Previously empty strings passed through requireString, causing cryptic API errors. Now validates early with clear error messages. Also removes unused configPath from input. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent eee424e commit 9982846

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/commands/input.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ export const input = (() => {
1313
main: requireString(positional[0], 'config entrypoint'),
1414
env: requireString(named.env || process.env.CLOUDFLARE_ENV || 'local', 'environment'),
1515
stateNamespace: requireString(named['state-namespace'] || 'cf-state', 'state namespace'),
16-
configPath: requireString(named.config || 'wrangler.jsonc', 'config path'),
17-
accountId: requireString(named['account-id'] || process.env.CLOUDFLARE_ACCOUNT_ID || '', 'account id'),
18-
apiToken: requireString(named['api-token'] || process.env.CLOUDFLARE_API_TOKEN || '', 'api token'),
16+
accountId: (named['account-id'] || process.env.CLOUDFLARE_ACCOUNT_ID || '') as string,
17+
apiToken: (named['api-token'] || process.env.CLOUDFLARE_API_TOKEN || '') as string,
1918
dryRun: !!named['dry-run'],
2019
remote: !!named.remote,
2120
destroy: !!named.destroy,

src/commands/run.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ registerSignalHandler()
1010
if (input.validate) {
1111
await CloudflareValidateExecutor.execute({ input })
1212
} else if (input.remote) {
13+
if (!input.accountId) {
14+
console.error('Missing --account-id or CLOUDFLARE_ACCOUNT_ID environment variable')
15+
process.exit(1)
16+
}
17+
if (!input.apiToken) {
18+
console.error('Missing --api-token or CLOUDFLARE_API_TOKEN environment variable')
19+
process.exit(1)
20+
}
1321
await CloudflareDeployExecutor.execute({ input })
1422
} else {
1523
await CloudflareConfigureExecutor.execute({ input })

0 commit comments

Comments
 (0)