xai-org/x-algorithm · error · ConfigFailure
Regex maximumCacheItems must be greater than 0
Error message
Regex maximumCacheItems must be greater than 0
What it means
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.
Source
Thrown at botmaker/src/scala/com/twitter/botmaker/runtime/config/RegexConfigs.scala:41
final def getRegexOptions: RegexConfig = regexOptions
final def addRegexOptions(config: RegexConfig): Unit = {
if (config.maximumPendingRequests <= 0) {
throw ConfigFailure(
s"Regex maximumPendingRequests must be greater than 0"
)
}
if (config.timeoutMilis <= 0) {
throw ConfigFailure(
s"Regex timeoutMilis must be greater than 0"
)
}
if (config.maximumCacheItems <= 0) {
throw ConfigFailure(
s"Regex maximumCacheItems must be greater than 0"
)
}
if (config.cacheExpirationMillis <= 0) {
throw ConfigFailure(
s"Regex cacheExpirationMillis must be greater than 0"
)
}
regexOptions = config
}
}
View on GitHub (pinned to 24c60942c5)
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
Example fix
// before regexOptions = RegexOptions( timeoutMillis = 1000, maximumCacheItems = 0, cacheExpirationMillis = 60000) // after regexOptions = RegexOptions( timeoutMillis = 1000, maximumCacheItems = 1024, cacheExpirationMillis = 60000)
Defensive patterns
Strategy: validation
Validate before calling
def validateRegexOptions(o): assert o.timeoutMillis > 0 and o.maximumCacheItems > 0 and o.cacheExpirationMillis > 0, f"bad regex options: {o}" Try / catch
try:
registerRegexOptions(opts)
except ConfigFailure as e:
if "maximumCacheItems" in str(e):
opts = replace(opts, maximumCacheItems=1024)
registerRegexOptions(opts)
else:
raise Prevention
- Centralize regex option construction with validated defaults
- Fail fast in unit tests on config assembly
When it happens
Trigger: 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.
Common situations: 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).
Understand the failure class
Background: Config validation failed: what "invalid value for {key}" and settings-rejection errors mean across 19 open-source libraries — this error's family across 19 libraries.
Related errors
- Regex cacheExpirationMillis must be greater than 0
- ScheduledEvent ${config.eventType} intervalMillis must be a
- Conflict config name:${nameSeq.mkString}
- Event type '$eventType' does not match $eventTypeRegex.
- Field name '$fieldName' does not match $fieldNameRegex.
AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28).
Data as JSON: /api/errors/3b9e981e46c1f816.
Report an issue: GitHub.