{"record":{"id":"c801b2922139a920","repo":"alibaba/Sentinel","slug":"invalid-maxfilesizemb","errorCode":null,"errorMessage":"Invalid maxFileSizeMB","messagePattern":"Invalid maxFileSizeMB","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sentinel-core/src/main/java/com/alibaba/csp/sentinel/eagleeye/BaseLoggerBuilder.java","lineNumber":66,"sourceCode":"        EagleEyeCoreUtils.checkNotNullEmpty(filePathToConfig, \"filePath\");\n        if (filePathToConfig.charAt(0) != '/') {\n            filePathToConfig = basePath + filePathToConfig;\n        }\n        this.filePath = filePathToConfig;\n        return (T)this;\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public T configLogFilePath(String filePath) {\n        EagleEyeCoreUtils.checkNotNullEmpty(filePath, \"filePath\");\n        this.filePath = filePath;\n        return (T)this;\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public T maxFileSizeMB(long maxFileSizeMB) {\n        if (maxFileSize < 10) {\n            throw new IllegalArgumentException(\"Invalid maxFileSizeMB\");\n        }\n        this.maxFileSize = maxFileSizeMB * 1024 * 1024;\n        return (T)this;\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public T maxBackupIndex(int maxBackupIndex) {\n        if (maxBackupIndex < 1) {\n            throw new IllegalArgumentException(\"\");\n        }\n        this.maxBackupIndex = maxBackupIndex;\n        return (T)this;\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public T entryDelimiter(char entryDelimiter) {\n        this.entryDelimiter = entryDelimiter;\n        return (T)this;","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/alibaba/Sentinel/blob/a3f40ba8e900c8489bd520274739f17235a7721c/sentinel-core/src/main/java/com/alibaba/csp/sentinel/eagleeye/BaseLoggerBuilder.java#L48-L84","documentation":"BaseLoggerBuilder.maxFileSizeMB(long) is meant to validate the log file size cap but contains a bug: it checks the *field* maxFileSize (< 10) instead of the parameter maxFileSizeMB. On a fresh builder the field defaults below 10, so the first call always throws IllegalArgumentException('Invalid maxFileSizeMB') regardless of the argument passed — making the API effectively unusable as written in this version.","triggerScenarios":"Any call to maxFileSizeMB(n) on a freshly built EagleEye logger builder (e.g. EagleEyeLogDaemon or Sentinel's own metric log builder initialization) in this code version; the check inspects maxFileSize (field, default value) not the method parameter.","commonSituations":"Upgrading Sentinel/eagleeye versions and suddenly hitting this at startup; custom code configuring eagleeye loggers with maxFileSizeMB.","solutions":["Upgrade to a Sentinel version where the check is fixed (validates the parameter), or patch locally to 'if (maxFileSizeMB < 10)'","Avoid the builder method: set max file size via the alternate configuration path if available, or use default sizing","If patching is impossible, reflectively set the maxFileSize field after constructing the builder"],"exampleFix":"// before (library bug)\nnew EagleEyeLoggerBuilder().maxFileSizeMB(50); // still throws\n\n// after (patched library / local fix)\npublic T maxFileSizeMB(long maxFileSizeMB) {\n    if (maxFileSizeMB < 10) {\n        throw new IllegalArgumentException(\"Invalid maxFileSizeMB\");\n    }\n    this.maxFileSize = maxFileSizeMB * 1024 * 1024;\n    return (T) this;\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    builder.maxFileSizeMB(sizeMb);\n} catch (IllegalArgumentException e) {\n    // known library bug in this version: field checked instead of parameter\n    // fall back to default sizing or set field via the fixed version\n}","preventionTips":["Pin a Sentinel version where maxFileSizeMB validates the parameter, or patch the class locally","Add a startup smoke test that builds the logger once so config bugs surface immediately"],"tags":["eagleeye","logging","library-bug","illegal-argument","core"],"backgroundTag":null,"analyzedSha":"a3f40ba8e900c8489bd520274739f17235a7721c","analyzedAt":"2026-08-14T11:10:30.678Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}