From 7f5e7407abe1937867ca287ffc1b6d6e1e5d662e Mon Sep 17 00:00:00 2001 From: "chenglun.hu" Date: Thu, 29 Jan 2026 08:56:14 +0800 Subject: [PATCH] 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 --- src/commands/configure.gateway.ts | 2 +- src/wizard/onboarding.gateway-config.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/configure.gateway.ts b/src/commands/configure.gateway.ts index 7ddfce3b6..3313b37ca 100644 --- a/src/commands/configure.gateway.ts +++ b/src/commands/configure.gateway.ts @@ -175,7 +175,7 @@ export async function promptGatewayConfig( }), runtime, ); - gatewayToken = String(tokenInput).trim() || randomToken(); + gatewayToken = (tokenInput ?? "").trim() || randomToken(); } if (authMode === "password") { diff --git a/src/wizard/onboarding.gateway-config.ts b/src/wizard/onboarding.gateway-config.ts index 1a097f42e..7d36ebae0 100644 --- a/src/wizard/onboarding.gateway-config.ts +++ b/src/wizard/onboarding.gateway-config.ts @@ -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(); } }