Prevent leaking OpenAI organization-ids in error responses (khanon/oai-reverse-proxy!5)

This commit is contained in:
gronon 2023-05-06 12:22:05 +00:00 committed by nai-degen
parent 432023f875
commit e0529197cd
1 changed files with 3 additions and 0 deletions

View File

@ -292,6 +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");
res.status(statusCode).json(errorPayload);
throw new Error(errorPayload.error?.message);