From f256cf80ac2e3c549fc44929aab2394552bc692c Mon Sep 17 00:00:00 2001 From: ionutboangiu Date: Tue, 18 Mar 2025 12:39:38 +0200 Subject: [PATCH] Add validation for positive TTL in file exporters --- config/configsanity.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/config/configsanity.go b/config/configsanity.go index 50fb276a2..053bede77 100644 --- a/config/configsanity.go +++ b/config/configsanity.go @@ -910,6 +910,18 @@ func (cfg *CGRConfig) checkConfigSanity() error { return fmt.Errorf("<%s> connection with id: <%s> not defined", utils.EEs, connID) } } + + // Check cache TTL for file exporters which require positive TTL as + // content is flushed only upon cache expiration. + for eeType, cacheCfg := range cfg.eesCfg.Cache { + if slices.Contains([]string{utils.MetaFileCSV, utils.MetaFileFWV}, eeType) { + if cacheCfg.TTL <= 0 { + return fmt.Errorf("<%s> exporter type %q requires positive cache TTL, got %v", + utils.EEs, eeType, cacheCfg.TTL) + } + } + } + for _, exp := range cfg.eesCfg.Exporters { if !possibleExporterTypes.Has(exp.Type) { return fmt.Errorf("<%s> unsupported data type: %s for exporter with ID: %s", utils.EEs, exp.Type, exp.ID)