alibaba/Sentinel · error · IllegalArgumentException

Invalid maxFileSizeMB

Error message

Invalid maxFileSizeMB

What it means

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.

Source

Thrown at sentinel-core/src/main/java/com/alibaba/csp/sentinel/eagleeye/BaseLoggerBuilder.java:66

        EagleEyeCoreUtils.checkNotNullEmpty(filePathToConfig, "filePath");
        if (filePathToConfig.charAt(0) != '/') {
            filePathToConfig = basePath + filePathToConfig;
        }
        this.filePath = filePathToConfig;
        return (T)this;
    }

    @SuppressWarnings("unchecked")
    public T configLogFilePath(String filePath) {
        EagleEyeCoreUtils.checkNotNullEmpty(filePath, "filePath");
        this.filePath = filePath;
        return (T)this;
    }

    @SuppressWarnings("unchecked")
    public T maxFileSizeMB(long maxFileSizeMB) {
        if (maxFileSize < 10) {
            throw new IllegalArgumentException("Invalid maxFileSizeMB");
        }
        this.maxFileSize = maxFileSizeMB * 1024 * 1024;
        return (T)this;
    }

    @SuppressWarnings("unchecked")
    public T maxBackupIndex(int maxBackupIndex) {
        if (maxBackupIndex < 1) {
            throw new IllegalArgumentException("");
        }
        this.maxBackupIndex = maxBackupIndex;
        return (T)this;
    }

    @SuppressWarnings("unchecked")
    public T entryDelimiter(char entryDelimiter) {
        this.entryDelimiter = entryDelimiter;
        return (T)this;

View on GitHub (pinned to a3f40ba8e9)

Solutions

  1. Upgrade to a Sentinel version where the check is fixed (validates the parameter), or patch locally to 'if (maxFileSizeMB < 10)'
  2. Avoid the builder method: set max file size via the alternate configuration path if available, or use default sizing
  3. If patching is impossible, reflectively set the maxFileSize field after constructing the builder

Example fix

// before (library bug)
new EagleEyeLoggerBuilder().maxFileSizeMB(50); // still throws

// after (patched library / local fix)
public T maxFileSizeMB(long maxFileSizeMB) {
    if (maxFileSizeMB < 10) {
        throw new IllegalArgumentException("Invalid maxFileSizeMB");
    }
    this.maxFileSize = maxFileSizeMB * 1024 * 1024;
    return (T) this;
}
Defensive patterns

Strategy: fallback

Try / catch

try {
    builder.maxFileSizeMB(sizeMb);
} catch (IllegalArgumentException e) {
    // known library bug in this version: field checked instead of parameter
    // fall back to default sizing or set field via the fixed version
}

Prevention

When it happens

Trigger: 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.

Common situations: Upgrading Sentinel/eagleeye versions and suddenly hitting this at startup; custom code configuring eagleeye loggers with maxFileSizeMB.

Related errors


AI-assisted analysis of alibaba/Sentinel@a3f40ba8e9 (2026-08-14). Data as JSON: /api/errors/c801b2922139a920. Report an issue: GitHub.