From 16e30686f043d659328e368b9f879b5cba0c9d26 Mon Sep 17 00:00:00 2001 From: clh02467605 Date: Thu, 10 Sep 2026 14:28:16 +0800 Subject: [PATCH] fix(speech): validate --words JSON before auth Invalid vocabulary JSON was parsed in run(), so CI without an API key failed with AUTH(3) instead of USAGE(2). --- .../src/commands/speech/vocabulary/shared.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/commands/src/commands/speech/vocabulary/shared.ts b/packages/commands/src/commands/speech/vocabulary/shared.ts index adb149f..7029f01 100644 --- a/packages/commands/src/commands/speech/vocabulary/shared.ts +++ b/packages/commands/src/commands/speech/vocabulary/shared.ts @@ -1,6 +1,7 @@ import { readTextFromPathOrStdin, parseVocabularyEntries, + UsageError, type FlagsDef, type ParsedFlags, type VocabularyEntry, @@ -61,6 +62,17 @@ export function validateVocabularySource(flags: VocabularySourceFlags): string | if (flags.words && flags.wordsFile) { return "Use either --words or --words-file, not both."; } + if (!flags.words) { + return undefined; + } + try { + parseVocabularyEntries(flags.words, flags.lang); + } catch (error) { + if (error instanceof UsageError) { + return error.message; + } + throw error; + } return undefined; }