Fix provider API key validation trimming (#810)

This commit is contained in:
Lingxuan Zuo
2026-04-10 15:15:29 +08:00
committed by GitHub
Unverified
parent 66b2ddb2dc
commit 49518300dc
7 changed files with 155 additions and 12 deletions

View File

@@ -1,5 +1,6 @@
import { describe, expect, it } from 'vitest';
import {
normalizeProviderApiKeyInput,
PROVIDER_TYPES,
PROVIDER_TYPE_INFO,
getProviderDocsUrl,
@@ -171,6 +172,7 @@ describe('provider metadata', () => {
});
it('normalizes provider API keys for save flow', () => {
expect(normalizeProviderApiKeyInput(' sk-test \n')).toBe('sk-test');
expect(resolveProviderApiKeyForSave('ollama', '')).toBe('ollama-local');
expect(resolveProviderApiKeyForSave('ollama', ' ')).toBe('ollama-local');
expect(resolveProviderApiKeyForSave('ollama', 'real-key')).toBe('real-key');