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

@ -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);