alibaba/Sentinel · error · IllegalArgumentException

baseFileName can't be null

Error message

baseFileName can't be null

What it means

MetricSearcher needs the metric file name keyword (e.g. alihot-metrics.log or sentinel-dashboard-metrics.log) to locate metric files in baseDir. A null baseFileName throws IllegalArgumentException because the searcher would have nothing to pattern-match file names against.

Source

Thrown at sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/metric/MetricSearcher.java:62

    /**
     * @param baseDir      metric文件所在目录
     * @param baseFileName metric文件名的关键字,比如 alihot-metrics.log
     */
    public MetricSearcher(String baseDir, String baseFileName) {
        this(baseDir, baseFileName, defaultCharset);
    }

    /**
     * @param baseDir      metric文件所在目录
     * @param baseFileName metric文件名的关键字,比如 alihot-metrics.log
     * @param charset
     */
    public MetricSearcher(String baseDir, String baseFileName, Charset charset) {
        if (baseDir == null) {
            throw new IllegalArgumentException("baseDir can't be null");
        }
        if (baseFileName == null) {
            throw new IllegalArgumentException("baseFileName can't be null");
        }
        if (charset == null) {
            throw new IllegalArgumentException("charset can't be null");
        }
        this.baseDir = baseDir;
        if (!baseDir.endsWith(File.separator)) {
            this.baseDir += File.separator;
        }
        this.baseFileName = baseFileName;
        metricsReader = new MetricsReader(charset);
    }

    /**
     * 从beginTime开始,检索recommendLines条(大概)记录。同一秒中的数据是原子的,不能分割成多次查询。
     *
     * @param beginTimeMs    检索的最小时间戳
     * @param recommendLines 查询最多想得到的记录条数,返回条数会尽可能不超过这个数字。但是为保证每一秒的数据不被分割,有时候
     *                       返回的记录条数会大于该数字。

View on GitHub (pinned to a3f40ba8e9)

Solutions

  1. Pass the metric file name keyword used by MetricWriter for the target app (usually appName + '-metrics.log').
  2. Verify the variable supplying baseFileName is initialized (not a failed property lookup returning null).
  3. If searching the dashboard's own metrics, use the same naming convention as the logs written under baseDir.

Example fix

// before
new MetricSearcher(baseDir, null);

// after
new MetricSearcher(baseDir, appName + "-metrics.log");
Defensive patterns

Strategy: validation

Validate before calling

String fileName = appName + "-metrics.log"; // deterministic, never null
new MetricSearcher(baseDir, fileName);

Prevention

When it happens

Trigger: new MetricSearcher(baseDir, null) or new MetricSearcher(baseDir, null, charset) — the second constructor argument is null.

Common situations: Passing a resource name loaded from a null system property or constant; building the searcher generically without deciding which app's metric files to query.

Related errors


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