From 812ace7f3c69e7bc95dcddde1aaaf0353aa139fc Mon Sep 17 00:00:00 2001 From: Andrey Epifancev Date: Mon, 28 Sep 2026 00:49:12 +0400 Subject: [PATCH] fix(core): guard the only redact() call in transcribe() so it truly cannot throw Refs #5 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01QKHeGuAYh4W1jNdjMConZa --- src/core/openai.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/core/openai.ts b/src/core/openai.ts index c93d63a..220d57f 100644 --- a/src/core/openai.ts +++ b/src/core/openai.ts @@ -130,11 +130,15 @@ export class OpenAiTranscriber implements Transcriber { apiKey = s.apiKey; boundary = makeBoundary(this.random); result = await this.request(s, audio, mime, signal, boundary); - if (!result.ok) result = { ...result, message: redact(result.message, { apiKey, boundary }) }; } catch (e) { - result = fail('temporary', redact(`внутренняя ошибка: ${errorText(e)}`, { apiKey, boundary })); + result = fail('temporary', `внутренняя ошибка: ${errorText(e)}`); + } + if (result.ok) return result; + try { + return { ...result, message: redact(result.message, { apiKey, boundary }) }; + } catch { + return { ...result, message: 'внутренняя ошибка' }; } - return result; } private request(