From 174726e28a83b71b7b2d7d051464280dd2ef65e5 Mon Sep 17 00:00:00 2001 From: Gustavo Madeira Santana Date: Wed, 22 Apr 2026 17:23:15 -0400 Subject: [PATCH] refactor: simplify support export redaction paths --- src/logging/diagnostic-support-export.ts | 46 ++++++++++++--------- src/logging/diagnostic-support-redaction.ts | 5 ++- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/src/logging/diagnostic-support-export.ts b/src/logging/diagnostic-support-export.ts index ef8db59d08a..3877356c693 100644 --- a/src/logging/diagnostic-support-export.ts +++ b/src/logging/diagnostic-support-export.ts @@ -584,6 +584,26 @@ function sanitizeLogTail(tail: LogTailPayload, options: SupportRedactionContext) }; } +function failedLogTail(error: unknown, redaction: SupportRedactionContext): SanitizedLogTail { + const redactedError = redactErrorForSupport(error, redaction); + return { + status: "failed", + file: "unavailable", + cursor: 0, + size: 0, + lineCount: 0, + truncated: false, + reset: false, + error: redactedError, + lines: [ + { + omitted: "log-tail-read-failed", + error: redactedError, + }, + ], + }; +} + async function collectSupportLogTail(params: { readLogTail: typeof readConfiguredLogTail; limit: number; @@ -597,23 +617,7 @@ async function collectSupportLogTail(params: { }); return sanitizeLogTail(tail, params.redaction); } catch (error) { - const redactedError = redactErrorForSupport(error, params.redaction); - return { - status: "failed", - file: "unavailable", - cursor: 0, - size: 0, - lineCount: 0, - truncated: false, - reset: false, - error: redactedError, - lines: [ - { - omitted: "log-tail-read-failed", - error: redactedError, - }, - ], - }; + return failedLogTail(error, params.redaction); } } @@ -661,6 +665,10 @@ function renderSummary(params: { const configLine = params.config.exists ? `config shape included (${params.config.parseOk ? "parsed" : "parse failed"})` : "config file not found"; + const logTailLine = + params.logTail.status === "failed" + ? `sanitized log tail unavailable (${params.logTail.error})` + : `sanitized log tail (${params.logTail.lineCount} line(s), inspected ${params.logTail.size} byte(s), raw messages omitted)`; const supportSnapshotLine = (label: string, snapshot: SupportSnapshotStatus) => { if (snapshot.status === "included") { return `${label} snapshot included (${snapshot.path})`; @@ -683,9 +691,7 @@ function renderSummary(params: { "## Contents", "", `- ${stabilityLine}`, - params.logTail.status === "failed" - ? `- sanitized log tail unavailable (${params.logTail.error})` - : `- sanitized log tail (${params.logTail.lineCount} line(s), inspected ${params.logTail.size} byte(s), raw messages omitted)`, + `- ${logTailLine}`, `- ${configLine}`, `- ${supportSnapshotLine("gateway status", params.status)}`, `- ${supportSnapshotLine("gateway health", params.health)}`, diff --git a/src/logging/diagnostic-support-redaction.ts b/src/logging/diagnostic-support-redaction.ts index bf283314ec2..f4699dea4bb 100644 --- a/src/logging/diagnostic-support-redaction.ts +++ b/src/logging/diagnostic-support-redaction.ts @@ -189,10 +189,11 @@ function sanitizeCommandArguments(args: unknown[], redaction: SupportRedactionCo return ""; } if (SENSITIVE_COMMAND_ARG_RE.test(arg)) { - if (!arg.includes("=")) { + const hasInlineValue = arg.includes("="); + if (!hasInlineValue) { redactNext = true; } - return arg.includes("=") ? arg.replace(/=.*/u, "=") : arg; + return hasInlineValue ? arg.replace(/=.*/u, "=") : arg; } return redactSupportString(arg, redaction); });