From 5a0b40658ae2219f6337e70217466d90b48d03c5 Mon Sep 17 00:00:00 2001 From: Richard R Date: Tue, 9 Jun 2026 09:17:10 -0600 Subject: [PATCH] fix(tts): honor explicit empty voices list in custom-openai probing extractVoiceNames collapsed an explicit `{ voices: [] }` response to null, which broke the existing contract of treating an empty list as a valid "no voices" answer. Distinguish a genuinely empty array (honored as []) from an array whose items yielded no usable names (unrecognized shape -> null, so the next endpoint or defaults apply). --- src/lib/server/tts/voice-resolution.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/lib/server/tts/voice-resolution.ts b/src/lib/server/tts/voice-resolution.ts index 7d02098..d447932 100644 --- a/src/lib/server/tts/voice-resolution.ts +++ b/src/lib/server/tts/voice-resolution.ts @@ -390,9 +390,16 @@ function extractVoiceNames(payload: unknown): string[] | null { } } } + // An explicitly empty list is a valid answer ("this server has no voices"); + // honor it rather than probing further or falling back to defaults. + if (value.length === 0) { + return []; + } const cleaned = Array.from( new Set(names.map((name) => name.trim()).filter((name) => name.length > 0)), ); + // The value was an array but yielded no usable names (unrecognized shape); + // treat as not-a-voices-list so the next endpoint / defaults can apply. return cleaned.length > 0 ? cleaned : null; };