From e602f8f4ab066683ece426f1937ebcb306a35b3e Mon Sep 17 00:00:00 2001 From: Gustavo Madeira Santana Date: Thu, 16 Apr 2026 18:58:46 -0400 Subject: [PATCH] refactor: clarify onboard health auth handling --- src/commands/onboard-non-interactive/local.ts | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/commands/onboard-non-interactive/local.ts b/src/commands/onboard-non-interactive/local.ts index ee541c4fc89..9d848a43aeb 100644 --- a/src/commands/onboard-non-interactive/local.ts +++ b/src/commands/onboard-non-interactive/local.ts @@ -101,10 +101,22 @@ export async function resolveGatewayHealthProbeToken( envFallback: "no-secret-ref", unresolvedReasonStyle: "detailed", }); - return { - ...(resolved.token ? { token: resolved.token } : {}), - ...(resolved.unresolvedRefReason ? { unresolvedRefReason: resolved.unresolvedRefReason } : {}), - }; + const probeAuth: { token?: string; unresolvedRefReason?: string } = {}; + if (resolved.token) { + probeAuth.token = resolved.token; + } + if (resolved.unresolvedRefReason) { + probeAuth.unresolvedRefReason = resolved.unresolvedRefReason; + } + return probeAuth; +} + +function formatGatewayHealthFailureDetail(params: { + probeDetail?: string; + unresolvedRefReason?: string; +}): string | undefined { + const detail = [params.probeDetail, params.unresolvedRefReason].filter(Boolean).join("\n"); + return detail || undefined; } export async function runNonInteractiveLocalSetup(params: { @@ -258,8 +270,10 @@ export async function runNonInteractiveLocalSetup(params: { : undefined, }); if (!probe.ok) { - const detail = - [probe.detail, probeAuth.unresolvedRefReason].filter(Boolean).join("\n") || undefined; + const detail = formatGatewayHealthFailureDetail({ + probeDetail: probe.detail, + unresolvedRefReason: probeAuth.unresolvedRefReason, + }); const diagnostics = opts.installDaemon ? await collectGatewayHealthFailureDiagnostics() : undefined;