From f35516c5c9efe3019f31b96d021a5531250d484c Mon Sep 17 00:00:00 2001 From: Kunal Karmakar Date: Sat, 21 Mar 2026 06:53:05 +0000 Subject: [PATCH] Add default value for config --- pkg/config/config.go | 2 +- pkg/config/config_test.go | 12 ++++++++++-- pkg/config/defaults.go | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 145a3893a..ddafc409d 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -245,7 +245,7 @@ type AgentDefaults struct { MaxMediaSize int `json:"max_media_size,omitempty" env:"PICOCLAW_AGENTS_DEFAULTS_MAX_MEDIA_SIZE"` Routing *RoutingConfig `json:"routing,omitempty"` ToolFeedback ToolFeedbackConfig `json:"tool_feedback,omitempty"` - LogLevel string `json:"log_level,omitempty" env:"PICOCLAW_LOG_LEVEL"` + LogLevel string `json:"log_level,omitempty" env:"PICOCLAW_LOG_LEVEL"` } const ( diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 131fd3237..45906ee70 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -470,6 +470,13 @@ func TestDefaultConfig_CronAllowCommandEnabled(t *testing.T) { } } +func TestDefaultConfig_LogLevel(t *testing.T) { + cfg := DefaultConfig() + if cfg.Agents.Defaults.LogLevel != "fatal" { + t.Errorf("LogLevel = %q, want \"fatal\"", cfg.Agents.Defaults.LogLevel) + } +} + func TestLoadConfig_OpenAIWebSearchDefaultsTrueWhenUnset(t *testing.T) { dir := t.TempDir() configPath := filepath.Join(dir, "config.json") @@ -1087,7 +1094,8 @@ func TestConfigLogLevelEmpty(t *testing.T) { if err != nil { t.Fatalf("LoadConfig: %v", err) } - if cfg.Agents.Defaults.LogLevel != "" { - t.Errorf("LogLevel = %q, want \"\"", cfg.Agents.Defaults.LogLevel) + // When config omits log_level, the DefaultConfig value ("fatal") is preserved. + if cfg.Agents.Defaults.LogLevel != "fatal" { + t.Errorf("LogLevel = %q, want \"fatal\"", cfg.Agents.Defaults.LogLevel) } } diff --git a/pkg/config/defaults.go b/pkg/config/defaults.go index 0d2141ae1..cec333888 100644 --- a/pkg/config/defaults.go +++ b/pkg/config/defaults.go @@ -26,6 +26,7 @@ func DefaultConfig() *Config { return &Config{ Agents: AgentsConfig{ Defaults: AgentDefaults{ + LogLevel: "fatal", Workspace: workspacePath, RestrictToWorkspace: true, Provider: "",