From bb3cb43e0957814f7dbba82ecffb07f85f76e3f4 Mon Sep 17 00:00:00 2001 From: fasilu Date: Fri, 28 Aug 2026 16:50:38 +0700 Subject: [PATCH] fix(dashboard): clamp API key mask length for short keys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "•".repeat(apiKey.length - 8) threw RangeError when the key was shorter than 8 chars, crashing the media-provider detail page. --- .../[kind]/[id]/components/GenericExampleCard.js | 2 +- .../media-providers/[kind]/[id]/components/SttExampleCard.js | 2 +- .../media-providers/[kind]/[id]/components/TtsExampleCard.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/(dashboard)/dashboard/media-providers/[kind]/[id]/components/GenericExampleCard.js b/src/app/(dashboard)/dashboard/media-providers/[kind]/[id]/components/GenericExampleCard.js index 76c571b8..ff30dcb2 100644 --- a/src/app/(dashboard)/dashboard/media-providers/[kind]/[id]/components/GenericExampleCard.js +++ b/src/app/(dashboard)/dashboard/media-providers/[kind]/[id]/components/GenericExampleCard.js @@ -275,7 +275,7 @@ export function GenericExampleCard({ providerId, kind }) { {/* API Key */} - {apiKey ? `${apiKey.slice(0, 8)}${"\u2022".repeat(Math.min(20, apiKey.length - 8))}` : No key configured} + {apiKey ? `${apiKey.slice(0, 8)}${"\u2022".repeat(Math.min(20, Math.max(0, apiKey.length - 8)))}` : No key configured} diff --git a/src/app/(dashboard)/dashboard/media-providers/[kind]/[id]/components/SttExampleCard.js b/src/app/(dashboard)/dashboard/media-providers/[kind]/[id]/components/SttExampleCard.js index 18f2a4f6..3cffdc42 100644 --- a/src/app/(dashboard)/dashboard/media-providers/[kind]/[id]/components/SttExampleCard.js +++ b/src/app/(dashboard)/dashboard/media-providers/[kind]/[id]/components/SttExampleCard.js @@ -157,7 +157,7 @@ export function SttExampleCard({ providerId }) { {/* API Key */} - {apiKey ? `${apiKey.slice(0, 8)}${"\u2022".repeat(Math.min(20, apiKey.length - 8))}` : No key configured} + {apiKey ? `${apiKey.slice(0, 8)}${"\u2022".repeat(Math.min(20, Math.max(0, apiKey.length - 8)))}` : No key configured} diff --git a/src/app/(dashboard)/dashboard/media-providers/[kind]/[id]/components/TtsExampleCard.js b/src/app/(dashboard)/dashboard/media-providers/[kind]/[id]/components/TtsExampleCard.js index a3fb1d32..e67a2594 100644 --- a/src/app/(dashboard)/dashboard/media-providers/[kind]/[id]/components/TtsExampleCard.js +++ b/src/app/(dashboard)/dashboard/media-providers/[kind]/[id]/components/TtsExampleCard.js @@ -274,7 +274,7 @@ export function TtsExampleCard({ providerId }) { {apiKey - ? `${apiKey.slice(0, 8)}${"•".repeat(Math.min(20, apiKey.length - 8))}` + ? `${apiKey.slice(0, 8)}${"•".repeat(Math.min(20, Math.max(0, apiKey.length - 8)))}` : connectionCount > 0 ? Using stored key(s) · {connectionCount} connection{connectionCount > 1 ? "s" : ""} : No key configured}