maybe fixes keychecker bricking on disabled org keys

This commit is contained in:
nai-degen
2023-08-30 12:29:58 -05:00
parent e462ad585e
commit 0a52ec478f
+2 -1
View File
@@ -225,6 +225,7 @@ export class OpenAIKeyProvider implements KeyProvider<OpenAIKey> {
const clone: OpenAIKey = {
...keyFromPool,
organizationId: orgId,
isDisabled: false,
hash: `oai-${crypto
.createHash("sha256")
.update(keyFromPool.key + orgId)
@@ -245,7 +246,7 @@ export class OpenAIKeyProvider implements KeyProvider<OpenAIKey> {
public disable(key: Key) {
const keyFromPool = this.keys.find((k) => k.hash === key.hash);
if (!keyFromPool || keyFromPool.isDisabled) return;
keyFromPool.isDisabled = true;
this.update(key.hash, { isDisabled: true });
this.log.warn({ key: key.hash }, "Key disabled");
}