From 39eb0b7bc0c2594620a7d2eff34f07d987845528 Mon Sep 17 00:00:00 2001 From: Gustavo Madeira Santana Date: Fri, 30 Jan 2026 16:15:54 -0500 Subject: [PATCH] fix: prevent undefined gateway token defaults (#4873) (thanks @Hisleren) Co-authored-by: Hisleren --- CHANGELOG.md | 1 + src/commands/onboard-helpers.test.ts | 4 ++-- src/commands/onboard-helpers.ts | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cdedb3cc..993dff71e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -74,6 +74,7 @@ Status: stable. - **BREAKING:** Gateway auth mode "none" is removed; gateway now requires token/password (Tailscale Serve identity still allowed). ### Fixes +- Gateway: prevent blank token prompts from storing "undefined". (#4873) Thanks @Hisleren. - Telegram: use undici fetch for per-account proxy dispatcher. (#4456) Thanks @spiceoogway. - Telegram: fix HTML nesting for overlapping styles and links. (#4578) Thanks @ThanhNguyxn. - Telegram: avoid silent empty replies by tracking normalization skips before fallback. (#3796) diff --git a/src/commands/onboard-helpers.test.ts b/src/commands/onboard-helpers.test.ts index 42c512310..e64a7cd1c 100644 --- a/src/commands/onboard-helpers.test.ts +++ b/src/commands/onboard-helpers.test.ts @@ -119,7 +119,7 @@ describe("normalizeGatewayTokenInput", () => { expect(normalizeGatewayTokenInput(" token ")).toBe("token"); }); - it("coerces non-string input to string", () => { - expect(normalizeGatewayTokenInput(123)).toBe("123"); + it("returns empty string for non-string input", () => { + expect(normalizeGatewayTokenInput(123)).toBe(""); }); }); diff --git a/src/commands/onboard-helpers.ts b/src/commands/onboard-helpers.ts index 03fcc9989..3c5ca6e39 100644 --- a/src/commands/onboard-helpers.ts +++ b/src/commands/onboard-helpers.ts @@ -63,8 +63,8 @@ export function randomToken(): string { } export function normalizeGatewayTokenInput(value: unknown): string { - if (value == null) return ""; - return String(value).trim(); + if (typeof value !== "string") return ""; + return value.trim(); } export function printWizardHeader(runtime: RuntimeEnv) {