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

@@ -246,9 +246,13 @@ export function resolveProviderModelForSave(
return trimmedModelId || provider?.defaultModelId || undefined;
}
export function normalizeProviderApiKeyInput(apiKey: string): string {
return apiKey.trim();
}
/** Normalize provider API key before saving; Ollama uses a local placeholder when blank. */
export function resolveProviderApiKeyForSave(type: ProviderType | string, apiKey: string): string | undefined {
const trimmed = apiKey.trim();
const trimmed = normalizeProviderApiKeyInput(apiKey);
if (type === 'ollama') {
return trimmed || OLLAMA_PLACEHOLDER_API_KEY;
}