From cce2dd9b9b65908457e959f12322da46a64dacb2 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Fri, 10 Apr 2026 23:43:15 +0800 Subject: [PATCH] fix(config): validate and fix invalid config combinations - Warn and auto-correct when fetch_interval_max < fetch_interval - Warn and auto-correct when log_report_max_latency < log_report_interval - log_report_batch_size <= 0 already handled by existing default check Co-Authored-By: Claude Opus 4.6 (1M context) --- internal/pkg/config/config.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/internal/pkg/config/config.go b/internal/pkg/config/config.go index d3ecfbcf..e19cb4c1 100644 --- a/internal/pkg/config/config.go +++ b/internal/pkg/config/config.go @@ -159,6 +159,18 @@ func LoadDefault(file string) (*Config, error) { cfg.Runner.StateReportInterval = 5 * time.Second } + // Validate and fix invalid config combinations to prevent confusing behavior. + if cfg.Runner.FetchIntervalMax < cfg.Runner.FetchInterval { + log.Warnf("fetch_interval_max (%v) is less than fetch_interval (%v), setting fetch_interval_max to fetch_interval", + cfg.Runner.FetchIntervalMax, cfg.Runner.FetchInterval) + cfg.Runner.FetchIntervalMax = cfg.Runner.FetchInterval + } + if cfg.Runner.LogReportMaxLatency < cfg.Runner.LogReportInterval { + log.Warnf("log_report_max_latency (%v) is less than log_report_interval (%v), setting log_report_max_latency to log_report_interval", + cfg.Runner.LogReportMaxLatency, cfg.Runner.LogReportInterval) + cfg.Runner.LogReportMaxLatency = cfg.Runner.LogReportInterval + } + // although `container.network_mode` will be deprecated, but we have to be compatible with it for now. if cfg.Container.NetworkMode != "" && cfg.Container.Network == "" { log.Warn("You are trying to use deprecated configuration item of `container.network_mode`, please use `container.network` instead.")