mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-25 04:55:19 +00:00
Added a check for characters which an API key cannot contain (#1227)
This commit is contained in:
1 parent
c72a1948b3
commit
e5a7f5423f
40 files changed
+1179
-71
No files matched your search
@@ -4,6 +4,7 @@ using AIStudio.Provider;
|
||||
using AIStudio.Provider.HuggingFace;
|
||||
using AIStudio.Tools.PluginSystem;
|
||||
using AIStudio.Tools.Services;
|
||||
using AIStudio.Tools.Validation;
|
||||
|
||||
using SharedTools;
|
||||
|
||||
@@ -221,17 +222,21 @@ public sealed record EmbeddingProvider(
|
||||
//
|
||||
// Queue the API key for storage in the OS keyring. A dry run only checks the
|
||||
// configuration, so it queues nothing: the start which follows it would
|
||||
// otherwise store the key once more for every dry run before it:
|
||||
// otherwise store the key once more for every dry run before it. A key which
|
||||
// cannot be sent is reported either way, so that a dry run tells about it too:
|
||||
//
|
||||
if (!dryRun)
|
||||
{
|
||||
PendingEnterpriseApiKeys.Add(new(
|
||||
var apiKeyIssue = dryRun
|
||||
? APIKeyValidation.Check(decryptedApiKey)
|
||||
: PendingEnterpriseApiKeys.Add(new(
|
||||
$"{ISecretId.ENTERPRISE_KEY_PREFIX}::{usedLLMProvider.SecretId}",
|
||||
name,
|
||||
decryptedApiKey,
|
||||
SecretStoreType.EMBEDDING_PROVIDER));
|
||||
|
||||
if (apiKeyIssue.IsProblem)
|
||||
LOGGER.LogWarning($"The API key for embedding provider {idx} contains a character which an API key cannot contain ({apiKeyIssue.Kind}). It will not be stored. (Plugin ID: {configPluginId})");
|
||||
else if (!dryRun)
|
||||
LOGGER.LogDebug($"Successfully decrypted API key for embedding provider {idx}. It will be stored in the OS keyring. (Plugin ID: {configPluginId})");
|
||||
}
|
||||
}
|
||||
else
|
||||
LOGGER.LogWarning($"Failed to decrypt API key for embedding provider {idx}. The encryption secret may be incorrect. (Plugin ID: {configPluginId})");
|
||||
|
||||
@@ -4,6 +4,7 @@ using AIStudio.Provider;
|
||||
using AIStudio.Provider.HuggingFace;
|
||||
using AIStudio.Tools.PluginSystem;
|
||||
using AIStudio.Tools.Services;
|
||||
using AIStudio.Tools.Validation;
|
||||
|
||||
using SharedTools;
|
||||
|
||||
@@ -242,17 +243,21 @@ public sealed record Provider(
|
||||
//
|
||||
// Queue the API key for storage in the OS keyring. A dry run only checks the
|
||||
// configuration, so it queues nothing: the start which follows it would
|
||||
// otherwise store the key once more for every dry run before it:
|
||||
// otherwise store the key once more for every dry run before it. A key which
|
||||
// cannot be sent is reported either way, so that a dry run tells about it too:
|
||||
//
|
||||
if (!dryRun)
|
||||
{
|
||||
PendingEnterpriseApiKeys.Add(new(
|
||||
var apiKeyIssue = dryRun
|
||||
? APIKeyValidation.Check(decryptedApiKey)
|
||||
: PendingEnterpriseApiKeys.Add(new(
|
||||
$"{ISecretId.ENTERPRISE_KEY_PREFIX}::{usedLLMProvider.SecretId}",
|
||||
instanceName,
|
||||
decryptedApiKey,
|
||||
SecretStoreType.LLM_PROVIDER));
|
||||
|
||||
if (apiKeyIssue.IsProblem)
|
||||
LOGGER.LogWarning($"The API key for provider {idx} contains a character which an API key cannot contain ({apiKeyIssue.Kind}). It will not be stored. (Plugin ID: {configPluginId})");
|
||||
else if (!dryRun)
|
||||
LOGGER.LogDebug($"Successfully decrypted API key for provider {idx}. It will be stored in the OS keyring. (Plugin ID: {configPluginId})");
|
||||
}
|
||||
}
|
||||
else
|
||||
LOGGER.LogWarning($"Failed to decrypt API key for provider {idx}. The encryption secret may be incorrect. (Plugin ID: {configPluginId})");
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Text.Json.Serialization;
|
||||
using AIStudio.Provider;
|
||||
using AIStudio.Provider.HuggingFace;
|
||||
using AIStudio.Tools.PluginSystem;
|
||||
using AIStudio.Tools.Validation;
|
||||
|
||||
using SharedTools;
|
||||
|
||||
@@ -184,17 +185,21 @@ public sealed record TranscriptionProvider(
|
||||
//
|
||||
// Queue the API key for storage in the OS keyring. A dry run only checks the
|
||||
// configuration, so it queues nothing: the start which follows it would
|
||||
// otherwise store the key once more for every dry run before it:
|
||||
// otherwise store the key once more for every dry run before it. A key which
|
||||
// cannot be sent is reported either way, so that a dry run tells about it too:
|
||||
//
|
||||
if (!dryRun)
|
||||
{
|
||||
PendingEnterpriseApiKeys.Add(new(
|
||||
var apiKeyIssue = dryRun
|
||||
? APIKeyValidation.Check(decryptedApiKey)
|
||||
: PendingEnterpriseApiKeys.Add(new(
|
||||
$"{ISecretId.ENTERPRISE_KEY_PREFIX}::{usedLLMProvider.SecretId}",
|
||||
name,
|
||||
decryptedApiKey,
|
||||
SecretStoreType.TRANSCRIPTION_PROVIDER));
|
||||
|
||||
if (apiKeyIssue.IsProblem)
|
||||
LOGGER.LogWarning($"The API key for transcription provider {idx} contains a character which an API key cannot contain ({apiKeyIssue.Kind}). It will not be stored. (Plugin ID: {configPluginId})");
|
||||
else if (!dryRun)
|
||||
LOGGER.LogDebug($"Successfully decrypted API key for transcription provider {idx}. It will be stored in the OS keyring. (Plugin ID: {configPluginId})");
|
||||
}
|
||||
}
|
||||
else
|
||||
LOGGER.LogWarning($"Failed to decrypt API key for transcription provider {idx}. The encryption secret may be incorrect. (Plugin ID: {configPluginId})");
|
||||
|
||||
Reference in new issue
Block a user