{"record":{"id":"d37ef9302d88ab36","repo":"crowdsecurity/crowdsec","slug":"unknown-cache-strategy-s","errorCode":null,"errorMessage":"unknown cache strategy '%s'","messagePattern":"unknown cache strategy '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/exprhelpers/helpers.go","lineNumber":177,"sourceCode":"\t\tsize = *cacheCfg.Size\n\t}\n\n\tgc := gcache.New(size)\n\n\tstrategy := \"LRU\"\n\tif cacheCfg.Strategy != \"\" {\n\t\tstrategy = cacheCfg.Strategy\n\t}\n\n\tswitch strategy {\n\tcase \"LRU\":\n\t\tgc = gc.LRU()\n\tcase \"LFU\":\n\t\tgc = gc.LFU()\n\tcase \"ARC\":\n\t\tgc = gc.ARC()\n\tdefault:\n\t\treturn fmt.Errorf(\"unknown cache strategy '%s'\", strategy)\n\t}\n\n\tif cacheCfg.TTL != nil {\n\t\tgc.Expiration(*cacheCfg.TTL)\n\t}\n\n\tcache := gc.Build()\n\tdataFileRegexCache[filename] = cache\n\n\treturn nil\n}\n\n// UpdateCacheMetrics is called directly by the prom handler\nfunc UpdateRegexpCacheMetrics() {\n\tmetrics.RegexpCacheMetrics.Reset()\n\n\tfor name := range dataFileRegexCache {\n\t\tmetrics.RegexpCacheMetrics.With(prometheus.Labels{\"name\": name}).Set(float64(dataFileRegexCache[name].Len(true)))","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/exprhelpers/helpers.go#L159-L195","documentation":"RegexpCacheInit configures a regexp cache (rafthrift/cache LRU/LFU/ARC builder) from a cache config. This error is thrown when the config's cache strategy string is not one of the recognized strategies, so no cache can be built.","triggerScenarios":"Calling RegexpCacheInit with a cache config whose strategy field is e.g. \"lru\" (lowercase), \"fifo\", \"none\", or any misspelling — the switch only matches \"LRU\", \"LFU\", \"ARC\" (and the empty/default case above it).","commonSituations":"Typos or wrong casing in config YAML for regexp cache settings; copying cache config from another project with different strategy names; enabling a strategy the embedded cache library doesn't support.","solutions":["Set the cache strategy to exactly \"LRU\", \"LFU\", or \"ARC\" (uppercase) in the config.","Check for casing errors — the switch is case-sensitive, so \"lru\" fails.","Consult the crowdsec docs for the supported strategy list rather than the underlying cache library's docs.","Remove the strategy key to fall back to the default case if one exists in the surrounding code."],"exampleFix":"// before (config)\ncache: { strategy: \"lru\", size: 100 }\n// after\ncache: { strategy: \"LRU\", size: 100 }","handlingStrategy":"validation","validationCode":"switch strategy {\ncase \"\", \"LRU\", \"LFU\", \"ARC\":\n\t// ok\ndefault:\n\treturn fmt.Errorf(\"unsupported cache strategy %q\", strategy)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only use LRU, LFU or ARC, spelled exactly and uppercase","Centralize cache strategy values in a config constant/enum instead of free-text YAML","Test config changes with cscli/crowdsec in a dev environment before rollout"],"tags":["config","cache","enum","crowdsec"],"backgroundTag":"invalid-config-value","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}