From 119c2f827a8a7c591b033f1b5dae5e8bf802adbc Mon Sep 17 00:00:00 2001 From: nai-degen <44111-khanon@users.noreply.gitgud.io> Date: Sat, 6 May 2023 09:51:09 -0500 Subject: [PATCH] fixes org-ID redaction on errors which don't include one --- src/proxy/middleware/response/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/proxy/middleware/response/index.ts b/src/proxy/middleware/response/index.ts index 40f5b19..28067f8 100644 --- a/src/proxy/middleware/response/index.ts +++ b/src/proxy/middleware/response/index.ts @@ -292,9 +292,9 @@ const handleDownstreamErrors: ProxyResHandlerWithBody = async ( } else { errorPayload.proxy_note = `Unrecognized error from OpenAI.`; } - - // Don't leak the org id outside the proxy - errorPayload.message.replace(/org-.{24}/gm, "org-xxxxxxxxxxxxxxxxxxx"); + + // Some OAI errors contain the organization ID, which we don't want to reveal. + errorPayload.message?.replace(/org-.{24}/gm, "org-xxxxxxxxxxxxxxxxxxx"); res.status(statusCode).json(errorPayload); throw new Error(errorPayload.error?.message);