Skip to content

Commit e3532fc

Browse files
bgrozevclaude
andauthored
fix: add openai_custom to error message and make ?provider= case-insensitive (#80)
* fix: add openai_custom to error message and make ?provider= case-insensitive Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix: accept custom_openai as alias for openai_custom in ?provider= param Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * squash: Add tests. --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 2cabb10 commit e3532fc

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ export function handleWebSocketConnection(ws: WebSocket, parameters: ISessionPar
265265
if (requestedProvider) {
266266
// Provider specified in URL
267267
if (!isValidProvider(requestedProvider)) {
268-
const errorMessage = `Invalid provider: ${requestedProvider}. Valid providers are: openai, gemini, deepgram, dummy`;
268+
const errorMessage = `Invalid provider: ${requestedProvider}. Valid providers are: openai, openai_custom, gemini, deepgram, dummy`;
269269
logger.error(`[WS-${connectionId}] ${errorMessage}`);
270270
ws.close(1002, errorMessage);
271271
return;

src/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ export function extractSessionParameters(url: string): ISessionParameters {
4545
const sendBack = parsedUrl.searchParams.get('sendBack');
4646
const sendBackInterim = parsedUrl.searchParams.get('sendBackInterim');
4747
const lang = parsedUrl.searchParams.get('lang');
48-
const provider = parsedUrl.searchParams.get('provider');
48+
const rawProvider = parsedUrl.searchParams.get('provider')?.toLowerCase();
49+
const provider = rawProvider === 'custom_openai' ? 'openai_custom' : rawProvider;
4950
const encodingParam = parsedUrl.searchParams.get('encoding');
5051
let encoding: AudioEncoding;
5152
if (encodingParam === null || encodingParam === 'opus') {

test/unit/utils.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,24 @@ describe('extractSessionParameters', () => {
5151
expect(params.tags).toEqual(['production', 'region-us']);
5252
});
5353

54+
it('should normalize provider to lowercase', () => {
55+
const url = 'ws://localhost:8080/transcribe?provider=Deepgram';
56+
const params = extractSessionParameters(url);
57+
expect(params.provider).toBe('deepgram');
58+
});
59+
60+
it('should map custom_openai alias to openai_custom', () => {
61+
const url = 'ws://localhost:8080/transcribe?provider=custom_openai';
62+
const params = extractSessionParameters(url);
63+
expect(params.provider).toBe('openai_custom');
64+
});
65+
66+
it('should map CUSTOM_OPENAI alias case-insensitively to openai_custom', () => {
67+
const url = 'ws://localhost:8080/transcribe?provider=CUSTOM_OPENAI';
68+
const params = extractSessionParameters(url);
69+
expect(params.provider).toBe('openai_custom');
70+
});
71+
5472
it('should filter out empty tag values', () => {
5573
const url = 'ws://localhost:8080/transcribe?sessionId=test&tag=&tag=valid';
5674
const params = extractSessionParameters(url);

0 commit comments

Comments
 (0)