fixes org-ID redaction on errors which don't include one

This commit is contained in:
nai-degen 2023-05-06 09:51:09 -05:00
parent e0529197cd
commit 119c2f827a
1 changed files with 3 additions and 3 deletions

View File

@ -293,8 +293,8 @@ const handleDownstreamErrors: ProxyResHandlerWithBody = async (
errorPayload.proxy_note = `Unrecognized error from OpenAI.`; errorPayload.proxy_note = `Unrecognized error from OpenAI.`;
} }
// Don't leak the org id outside the proxy // Some OAI errors contain the organization ID, which we don't want to reveal.
errorPayload.message.replace(/org-.{24}/gm, "org-xxxxxxxxxxxxxxxxxxx"); errorPayload.message?.replace(/org-.{24}/gm, "org-xxxxxxxxxxxxxxxxxxx");
res.status(statusCode).json(errorPayload); res.status(statusCode).json(errorPayload);
throw new Error(errorPayload.error?.message); throw new Error(errorPayload.error?.message);