From e503c87c18e7e02bc9c3dbc13f43b279f0cca469 Mon Sep 17 00:00:00 2001 From: I Putu Eddy Irawan Date: Tue, 3 Mar 2026 22:14:25 +0700 Subject: [PATCH] fix: add LiteLLM to env overrides and fix malformed .env test - Add missing LITELLM entry to loadProviderEnvOverrides so PICOCLAW_PROVIDERS_LITELLM_API_KEY/API_BASE env vars work - Replace valid .env content in TestLoadConfig_MalformedDotenv_NonFatal with genuinely malformed content (bare key without '=') to actually exercise the non-fatal error path Co-Authored-By: Claude Opus 4.6 --- pkg/config/config.go | 1 + pkg/config/config_test.go | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 9fe4142f7..793156be0 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -868,6 +868,7 @@ func loadProviderEnvOverrides(cfg *Config) { }{ {"ANTHROPIC", &cfg.Providers.Anthropic.APIKey, &cfg.Providers.Anthropic.APIBase}, {"OPENAI", &cfg.Providers.OpenAI.APIKey, &cfg.Providers.OpenAI.APIBase}, + {"LITELLM", &cfg.Providers.LiteLLM.APIKey, &cfg.Providers.LiteLLM.APIBase}, {"OPENROUTER", &cfg.Providers.OpenRouter.APIKey, &cfg.Providers.OpenRouter.APIBase}, {"GROQ", &cfg.Providers.Groq.APIKey, &cfg.Providers.Groq.APIBase}, {"ZHIPU", &cfg.Providers.Zhipu.APIKey, &cfg.Providers.Zhipu.APIBase}, diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 9b1be848b..fb11799d4 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -532,13 +532,14 @@ func TestLoadConfig_MalformedDotenv_NonFatal(t *testing.T) { t.Fatalf("WriteFile config: %v", err) } - // Write a malformed .env file (missing value after '=') + // Write a .env file with genuinely malformed content (bare key without '=', + // mixed with a valid line) to verify godotenv.Load errors are non-fatal. envFile := filepath.Join(dir, ".env") - if err := os.WriteFile(envFile, []byte("VALID_KEY=valid_value\n"), 0o600); err != nil { + if err := os.WriteFile(envFile, []byte("THIS_LINE_HAS_NO_EQUALS\nVALID_KEY=valid_value\n"), 0o600); err != nil { t.Fatalf("WriteFile .env: %v", err) } - // LoadConfig should not fail even with unusual .env content + // LoadConfig should not fail even with malformed .env content cfg, err := LoadConfig(configPath) if err != nil { t.Fatalf("LoadConfig() should not fail with .env issues, got error: %v", err)