{"record":{"id":"19c86a724fd79c0a","repo":"alibaba/Sentinel","slug":"max-entry-count-should-be-at-least-1","errorCode":null,"errorMessage":"Max entry count should be at least 1: ","messagePattern":"Max entry count should be at least 1: ","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sentinel-core/src/main/java/com/alibaba/csp/sentinel/eagleeye/StatLoggerBuilder.java","lineNumber":47,"sourceCode":"    private char keyDelimiter = ',';\n\n    private char valueDelimiter = ',';\n\n    private EagleEyeAppender appender = null;\n\n    StatLoggerBuilder(String loggerName) {\n        super(loggerName);\n    }\n\n    public StatLoggerBuilder intervalSeconds(int intervalSeconds) {\n        validateInterval(intervalSeconds);\n        this.intervalSeconds = intervalSeconds;\n        return this;\n    }\n\n    public StatLoggerBuilder maxEntryCount(int maxEntryCount) {\n        if (maxEntryCount < 1) {\n            throw new IllegalArgumentException(\"Max entry count should be at least 1: \" + maxEntryCount);\n        }\n        this.maxEntryCount = maxEntryCount;\n        return this;\n    }\n\n    public StatLoggerBuilder keyDelimiter(char keyDelimiter) {\n        this.keyDelimiter = keyDelimiter;\n        return this;\n    }\n\n    public StatLoggerBuilder valueDelimiter(char valueDelimiter) {\n        this.valueDelimiter = valueDelimiter;\n        return this;\n    }\n\n    StatLoggerBuilder appender(EagleEyeAppender appender) {\n        this.appender = appender;\n        return this;","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/alibaba/Sentinel/blob/a3f40ba8e900c8489bd520274739f17235a7721c/sentinel-core/src/main/java/com/alibaba/csp/sentinel/eagleeye/StatLoggerBuilder.java#L29-L65","documentation":"StatLoggerBuilder.maxEntryCount(int) validates the per-logger entry limit: an EagleEye stat logger caps how many distinct key combinations (entries) it tracks to bound memory. Any value below 1 is rejected with IllegalArgumentException because a logger that can hold zero entries is meaningless.","triggerScenarios":"Calling .maxEntryCount(0) or a negative value on a StatLoggerBuilder — commonly when the limit is read from configuration or a system property that is unset (parsed as 0/-1) or defaulted incorrectly.","commonSituations":"maxEntryCount wired from a config key that is missing in a new environment. A property placeholder like ${stat.max.entries} that fails to resolve and becomes 0. Arithmetic that derives the count (e.g. base - reserve) going negative under some inputs.","solutions":["Set a positive entry count (e.g. the EagleEye-typical default of 1000 or your measured cardinality) in the builder call.","If the value comes from config, validate it at startup and fall back to a sane default before building the logger.","Add a startup config check so misparsed numbers surface immediately with the config key name."],"exampleFix":"// before\nint maxEntries = Integer.getInteger(\"stat.max.entries\", 0);\nStatLogger logger = EagleEye.statLoggerBuilder(\"myStat\").maxEntryCount(maxEntries).build();\n\n// after\nint maxEntries = Integer.getInteger(\"stat.max.entries\", 1000);\nif (maxEntries < 1) { throw new IllegalStateException(\"stat.max.entries must be >= 1, got \" + maxEntries); }\nStatLogger logger = EagleEye.statLoggerBuilder(\"myStat\").maxEntryCount(maxEntries).build();","handlingStrategy":"validation","validationCode":"int maxEntries = Integer.getInteger(\"stat.max.entries\", 1000);\nif (maxEntries < 1) {\n    throw new IllegalStateException(\"stat.max.entries must be >= 1, got \" + maxEntries);\n}\nbuilder.maxEntryCount(maxEntries);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default every cardinality config to a positive number (e.g. 1000).","Validate numeric config at load time with clear error messages naming the key.","Watch for derived values (base - reserve) that can go non-positive."],"tags":["eagleeye","stat-logger","config","validation","illegal-argument","sentinel"],"backgroundTag":null,"analyzedSha":"a3f40ba8e900c8489bd520274739f17235a7721c","analyzedAt":"2026-08-14T11:10:30.678Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}