fix(wizard): handle undefined token input during onboarding

When user leaves token blank during onboarding or `configure gateway`,
`text()` may return `undefined` at runtime (despite TypeScript type
declaring `string`). `String(undefined)` produces the literal string
"undefined" which is truthy, so `randomToken()` was never called.

Fix: Use nullish coalescing `(tokenInput ?? "")` to convert undefined
to empty string before `.trim()`, allowing the `|| randomToken()`
fallback to work correctly.

Fixes #3384

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
chenglun.hu 2026-01-29 08:56:14 +08:00
parent fdcac0ccf4
commit 7f5e7407ab
No known key found for this signature in database
GPG Key ID: 11ECC6E33B83267C
2 changed files with 2 additions and 2 deletions

View File

@ -175,7 +175,7 @@ export async function promptGatewayConfig(
}),
runtime,
);
gatewayToken = String(tokenInput).trim() || randomToken();
gatewayToken = (tokenInput ?? "").trim() || randomToken();
}
if (authMode === "password") {

View File

@ -180,7 +180,7 @@ export async function configureGatewayForOnboarding(
placeholder: "Needed for multi-machine or non-loopback access",
initialValue: quickstartGateway.token ?? "",
});
gatewayToken = String(tokenInput).trim() || randomToken();
gatewayToken = (tokenInput ?? "").trim() || randomToken();
}
}