{"record":{"id":"3b9e981e46c1f816","repo":"xai-org/x-algorithm","slug":"regex-maximumcacheitems-must-be-greater-than-0","errorCode":null,"errorMessage":"Regex maximumCacheItems must be greater than 0","messagePattern":"Regex maximumCacheItems must be greater than 0","errorType":"validation","errorClass":"ConfigFailure","httpStatus":null,"severity":"error","filePath":"botmaker/src/scala/com/twitter/botmaker/runtime/config/RegexConfigs.scala","lineNumber":41,"sourceCode":"\n  final def getRegexOptions: RegexConfig = regexOptions\n\n  final def addRegexOptions(config: RegexConfig): Unit = {\n\n    if (config.maximumPendingRequests <= 0) {\n      throw ConfigFailure(\n        s\"Regex maximumPendingRequests must be greater than 0\"\n      )\n    }\n\n    if (config.timeoutMilis <= 0) {\n      throw ConfigFailure(\n        s\"Regex timeoutMilis must be greater than 0\"\n      )\n    }\n\n    if (config.maximumCacheItems <= 0) {\n      throw ConfigFailure(\n        s\"Regex maximumCacheItems must be greater than 0\"\n      )\n    }\n\n    if (config.cacheExpirationMillis <= 0) {\n      throw ConfigFailure(\n        s\"Regex cacheExpirationMillis must be greater than 0\"\n      )\n    }\n\n    regexOptions = config\n  }\n}\n","sourceCodeStart":23,"sourceCodeEnd":55,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/scala/com/twitter/botmaker/runtime/config/RegexConfigs.scala#L23-L55","documentation":"BotMaker's regex subsystem validates its RegexOptions config at registration time. maximumCacheItems controls the size of the compiled-regex LRU/expiration cache, and a non-positive value would make the cache unusable (zero or negative capacity), so ConfigFailure is thrown during config validation before any regex runs.","triggerScenarios":"Calling the regex config setter with RegexOptions where maximumCacheItems <= 0, e.g. maximumCacheItems = 0 or a negative number, during service/bot config assembly at startup.","commonSituations":"Copying a config template and forgetting to fill in cache size; deriving maximumCacheItems from an unset env var or config key that defaults to 0; disabling the cache intentionally by setting 0 (not supported).","solutions":["Set maximumCacheItems to a positive value (e.g. 1024) in the RegexOptions you register","If the value comes from a config file/env var, check for typos or missing keys that yield 0","If you intended no caching, pick a small positive value; zero-capacity caches are not supported"],"exampleFix":"// before\nregexOptions = RegexOptions(\n  timeoutMillis = 1000,\n  maximumCacheItems = 0,\n  cacheExpirationMillis = 60000)\n\n// after\nregexOptions = RegexOptions(\n  timeoutMillis = 1000,\n  maximumCacheItems = 1024,\n  cacheExpirationMillis = 60000)","handlingStrategy":"validation","validationCode":"def validateRegexOptions(o): assert o.timeoutMillis > 0 and o.maximumCacheItems > 0 and o.cacheExpirationMillis > 0, f\"bad regex options: {o}\"","typeGuard":null,"tryCatchPattern":"try:\n    registerRegexOptions(opts)\nexcept ConfigFailure as e:\n    if \"maximumCacheItems\" in str(e):\n        opts = replace(opts, maximumCacheItems=1024)\n        registerRegexOptions(opts)\n    else:\n        raise","preventionTips":["Centralize regex option construction with validated defaults","Fail fast in unit tests on config assembly"],"tags":["botmaker","scala","config-validation","regex-cache"],"backgroundTag":"config-validation-failed","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}