GoogleChrome/lighthouse · error

No metrics for ${metric} ${lanternMetric} ${lanternOrBaselin

Error message

No metrics for ${metric} ${lanternMetric} ${lanternOrBaseline}

What it means

Thrown by evaluateAccuracy() during per-entry iteration. After combineBaselineAndComputedDatasets returns entries that have both .lantern and .baseline, this function reads entry[lanternOrBaseline] to select which metric source to compare against WPT targets. If that property is falsy on a specific entry, the per-entry contract was violated — the entry was supposed to have data for the requested source.

Source

Thrown at core/scripts/lantern/constants.js:152

      metric,
      lanternMetric,
    };
  },

  /**
   * @param {LanternSiteDefinition[]} entries
   * @param {keyof TargetMetrics} metric
   * @param {keyof LanternMetrics} lanternMetric
   * @param {'lantern'|'baseline'} lanternOrBaseline
   * @return {EstimateEvaluationSummary}
   */
  evaluateAccuracy(entries, metric, lanternMetric, lanternOrBaseline = 'lantern') {
    const evaluations = [];

    const percentErrors = [];
    for (const entry of entries) {
      const actualMetrics = entry[lanternOrBaseline];
      if (!actualMetrics) throw new Error(`No metrics for ${metric} ${lanternMetric} ${lanternOrBaseline}`);

      const evaluation = this.evaluateSite(
        entry,
        entry.wpt3g,
        actualMetrics,
        metric,
        lanternMetric
      );

      // No data was available at all, skip it.
      if (!evaluation) continue;

      // Data was supposed to be available, but one metric was missing, warn.
      if (!Number.isFinite(evaluation.diff)) {
        const missingMetric = Number.isFinite(entry.wpt3g[metric]) ? lanternMetric : metric;
        const message = `WARNING: ${evaluation.url} was missing values for ${missingMetric}`;
        WARNINGS.push(message);
        continue;

View on GitHub (pinned to 9515cd4e58)

Solutions

  1. Only pass entries produced by combineBaselineAndComputedDatasets into evaluateAccuracy — that function guarantees both .lantern and .baseline exist
  2. If calling with a custom entries array, pre-filter: entries.filter(e => e[lanternOrBaseline])
  3. Verify the baseline fixture covers all URLs in the site index

Example fix

// before — may throw if some entries lack baseline
const result = constants.evaluateAccuracy(entries, metric, lanternMetric, 'baseline');

// after — filter to entries that have the requested source
const filtered = entries.filter(e => e[lanternOrBaseline]);
const result = constants.evaluateAccuracy(filtered, metric, lanternMetric, lanternOrBaseline);
Defensive patterns

Strategy: validation

Validate before calling

// Filter entries to only those with the requested metric source
const source = lanternOrBaseline; // 'lantern' or 'baseline'
const validEntries = entries.filter(e => e[source] != null);
if (!validEntries.length) {
  throw new Error(`No entries have ${source} metrics`);
}
const result = constants.evaluateAccuracy(validEntries, metric, lanternMetric, source);

Type guard

/** @param {any} entry @param {string} source @returns {boolean} */
function hasMetricSource(entry, source) {
  return entry != null && typeof entry === 'object' && entry[source] != null && typeof entry[source] === 'object';
}

Prevention

When it happens

Trigger: Called from evaluateAndPrintAccuracy in print-correlations.js (lines 96-97) with lanternOrBaseline='lantern' (default) and 'baseline', and from evaluateAllMetrics (constants.js:192). Fires when an entry passed into evaluateAccuracy has a falsy entry[lanternOrBaseline] — e.g., calling with 'baseline' on entries where some lack .baseline, or calling with 'lantern' on entries where .lantern is missing.

Common situations: Calling evaluateAccuracy with lanternOrBaseline='baseline' on an entries array not filtered by combineBaselineAndComputedDatasets (which guarantees both sources exist). Manually constructing an entries array with partial data. A baseline fixture that's missing some URLs, combined with entries that passed the combine filter via .lantern alone.

Related errors


AI-assisted analysis of GoogleChrome/lighthouse@9515cd4e58 (2026-08-13). Data as JSON: /api/errors/a7e4b359b91dbf96. Report an issue: GitHub.