Skip to content

Commit 2bcf994

Browse files
committed
fix: update configuration keys and validation logic in ConfigurationChecker and tests
- config detection was both using invalid keys and inconsistent with ssh key files and agent detection. resolved keys and logic issue
1 parent 427c6c2 commit 2bcf994

2 files changed

Lines changed: 144 additions & 151 deletions

File tree

src/Infrastructure/Configuration/ConfigurationChecker.cs

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,36 @@ public static class ConfigurationChecker
1717
/// <returns>True if configured, false if setup is needed</returns>
1818
public static bool IsConfigured(IConfiguration configuration, ILogger logger)
1919
{
20-
// Check for required configuration keys
21-
string? sshKeyPath = configuration["TenSecondTom:Auth:PublicKeyPath"];
22-
string? llmProvider = configuration["TenSecondTom:LlmProvider"];
23-
string? memoryDirectory = configuration["TenSecondTom:MemoryDirectory"];
24-
25-
// Check for API keys based on provider
26-
string? apiKey = llmProvider?.ToLowerInvariant() switch
27-
{
28-
"openai" => configuration["OPENAI_API_KEY"] ??
29-
Environment.GetEnvironmentVariable("OPENAI_API_KEY"),
30-
"anthropic" => configuration["ANTHROPIC_API_KEY"] ??
31-
Environment.GetEnvironmentVariable("ANTHROPIC_API_KEY"),
32-
_ => null
33-
};
20+
// Check for required configuration keys (matching UserSecretsStorageService format)
21+
// Keys are stored as: Ssh:KeyPath, Llm:Provider, Llm:ApiKey, Storage:MemoryDirectory
22+
// Note: Either Ssh:KeyPath OR Ssh:KeySource must be present (agents don't need KeyPath)
23+
string? sshKeyPath = configuration["Ssh:KeyPath"];
24+
string? sshKeySource = configuration["Ssh:KeySource"];
25+
string? llmProvider = configuration["Llm:Provider"];
26+
string? llmApiKey = configuration["Llm:ApiKey"];
27+
string? memoryDirectory = configuration["Storage:MemoryDirectory"];
28+
29+
// SSH is configured if either KeyPath is set OR KeySource is set
30+
bool hasSshConfiguration = !string.IsNullOrWhiteSpace(sshKeyPath) ||
31+
!string.IsNullOrWhiteSpace(sshKeySource);
3432

35-
bool isConfigured = !string.IsNullOrWhiteSpace(sshKeyPath) &&
33+
bool isConfigured = hasSshConfiguration &&
3634
!string.IsNullOrWhiteSpace(llmProvider) &&
3735
!string.IsNullOrWhiteSpace(memoryDirectory) &&
38-
!string.IsNullOrWhiteSpace(apiKey);
36+
!string.IsNullOrWhiteSpace(llmApiKey);
3937

4038
if (!isConfigured)
4139
{
4240
logger.LogInformation("Application is not configured. Setup wizard will be launched.");
4341

44-
if (string.IsNullOrWhiteSpace(sshKeyPath))
45-
logger.LogDebug("Missing: SSH key path");
42+
if (!hasSshConfiguration)
43+
logger.LogDebug("Missing: SSH configuration (neither Ssh:KeyPath nor Ssh:KeySource is set)");
4644
if (string.IsNullOrWhiteSpace(llmProvider))
47-
logger.LogDebug("Missing: LLM provider");
45+
logger.LogDebug("Missing: LLM provider (Llm:Provider)");
4846
if (string.IsNullOrWhiteSpace(memoryDirectory))
49-
logger.LogDebug("Missing: Memory directory");
50-
if (string.IsNullOrWhiteSpace(apiKey))
51-
logger.LogDebug("Missing: API key for provider {Provider}", llmProvider ?? "unknown");
47+
logger.LogDebug("Missing: Memory directory (Storage:MemoryDirectory)");
48+
if (string.IsNullOrWhiteSpace(llmApiKey))
49+
logger.LogDebug("Missing: LLM API key (Llm:ApiKey)");
5250
}
5351

5452
return isConfigured;

0 commit comments

Comments
 (0)