From 00c9e6611ebfee05833637760fbd1af1a62055aa Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Wed, 27 Sep 2023 10:08:59 -0400 Subject: [PATCH] Fixes #2940 relaxes OpenAI key validation --- CHANGELOG.md | 1 + src/ai/openaiProvider.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 358fdf3..d02393a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ### Fixed +- Fixes [#2940](https://github.com/gitkraken/vscode-gitlens/issues/2940) - Can't use Azure OpenAI model because i can't save the openai key because of the verification - Fixes [#2928](https://github.com/gitkraken/vscode-gitlens/issues/2928) - Apply Changes should create new files when needed - Fixes [#2896](https://github.com/gitkraken/vscode-gitlens/issues/2896) - Repositories view stuck in loading state - Fixes issue with "View as [List|Tree]" toggle not working in the _Commit Details_ view diff --git a/src/ai/openaiProvider.ts b/src/ai/openaiProvider.ts index d3870f0..dd25a78 100644 --- a/src/ai/openaiProvider.ts +++ b/src/ai/openaiProvider.ts @@ -174,7 +174,7 @@ async function getApiKey(storage: Storage): Promise { disposables.push( input.onDidHide(() => resolve(undefined)), input.onDidChangeValue(value => { - if (value && !/sk-[a-zA-Z0-9]{32}/.test(value)) { + if (value && !/(?:sk-)?[a-zA-Z0-9]{32}/.test(value)) { input.validationMessage = 'Please enter a valid OpenAI API key'; return; } @@ -182,7 +182,7 @@ async function getApiKey(storage: Storage): Promise { }), input.onDidAccept(() => { const value = input.value.trim(); - if (!value || !/sk-[a-zA-Z0-9]{32}/.test(value)) { + if (!value || !/(?:sk-)?[a-zA-Z0-9]{32}/.test(value)) { input.validationMessage = 'Please enter a valid OpenAI API key'; return; }