Skip to content

Commit 16e3068

Browse files
committed
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).
1 parent 7803d91 commit 16e3068

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

  • packages/commands/src/commands/speech/vocabulary

packages/commands/src/commands/speech/vocabulary/shared.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
readTextFromPathOrStdin,
33
parseVocabularyEntries,
4+
UsageError,
45
type FlagsDef,
56
type ParsedFlags,
67
type VocabularyEntry,
@@ -61,6 +62,17 @@ export function validateVocabularySource(flags: VocabularySourceFlags): string |
6162
if (flags.words && flags.wordsFile) {
6263
return "Use either --words or --words-file, not both.";
6364
}
65+
if (!flags.words) {
66+
return undefined;
67+
}
68+
try {
69+
parseVocabularyEntries(flags.words, flags.lang);
70+
} catch (error) {
71+
if (error instanceof UsageError) {
72+
return error.message;
73+
}
74+
throw error;
75+
}
6476
return undefined;
6577
}
6678

0 commit comments

Comments
 (0)