GoogleChrome/lighthouse · error · Error

JSON file was not generated by Lighthouse

Error message

JSON file was not generated by Lighthouse

What it means

Thrown by the viewer's _validateReportJson when a loaded JSON object has no 'lighthouseVersion' field — the basic marker that a file was produced by Lighthouse. This is the first check in report validation; a missing version short-circuits before the version-comparison logic runs. (Older/lower versions only produce a warning, not this error.)

Source

Thrown at viewer/app/src/lighthouse-report-viewer.js:161

        .then(resp => resp.json())
        .then(json => {
          this._reportIsFromJSON = true;
          this._replaceReportHtml(json);
        })
        .catch(err => logger.error(err.message));
    }

    return loadPromise.finally(() => this._toggleLoadingBlur(false));
  }

  /**
   * Basic Lighthouse report JSON validation.
   * @param {LH.Result} reportJson
   * @private
   */
  _validateReportJson(reportJson) {
    if (!reportJson.lighthouseVersion) {
      throw new Error('JSON file was not generated by Lighthouse');
    }

    // Leave off patch version in the comparison.
    const semverRe = new RegExp(/^(\d+)?\.(\d+)?\.(\d+)$/);
    const reportVersion = reportJson.lighthouseVersion.replace(semverRe, '$1.$2');
    const lhVersion = window.LH_CURRENT_VERSION.replace(semverRe, '$1.$2');

    if (reportVersion < lhVersion) {
      // TODO: figure out how to handler older reports. All permalinks to older
      // reports will start to throw this warning when the viewer rev's its
      // minor LH version.
      // See https://github.com/GoogleChrome/lighthouse/issues/1108
      logger.warn('Results may not display properly.\n' +
                  'Report was created with an earlier version of ' +
                  `Lighthouse (${reportJson.lighthouseVersion}). The latest ` +
                  `version is ${window.LH_CURRENT_VERSION}.`);
    }
  }

View on GitHub (pinned to 9515cd4e58)

Solutions

  1. Load a genuine Lighthouse report JSON (it includes lighthouseVersion at the top level).
  2. Pre-validate the file before loading: check json.lighthouseVersion exists.
  3. Show a clear message that the selected file is not a Lighthouse report.

Example fix

// before
this._replaceReportHtml(json); // json has no lighthouseVersion

// after
if (!json?.lighthouseVersion) {
  logger.error('Selected file is not a Lighthouse report');
  return;
}
this._validateReportJson(json);
this._replaceReportHtml(json);
Defensive patterns

Strategy: validation

Validate before calling

function isLighthouseReport(json) {
  return json != null && typeof json === 'object' && typeof json.lighthouseVersion === 'string';
}
if (!isLighthouseReport(json)) {
  logger.error('Selected file is not a Lighthouse report');
} else {
  this._validateReportJson(json);
  this._replaceReportHtml(json);
}

Type guard

/** @param {unknown} j */
function looksLikeLighthouseReport(j) {
  return j != null && typeof j === 'object' && typeof /** @type {any} */ (j).lighthouseVersion === 'string';
}

Try / catch

try {
  this._validateReportJson(json);
} catch (err) {
  if (err.message === 'JSON file was not generated by Lighthouse') {
    logger.error('This file is not a Lighthouse report.');
  } else throw err;
}

Prevention

When it happens

Trigger: Loading any JSON file into the viewer that is not a Lighthouse Result — e.g. a random JSON config, a PSI raw response wrapper without a version, a hand-edited object, or the wrong file selected by the user.

Common situations: User picks the wrong file; loading a partial/truncated LHR; integrating a JSON source that omits lighthouseVersion.

Related errors


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