GoogleChrome/lighthouse · error · Error

Failed to find a Lighthouse report (*${GithubApi.LH_JSON_EXT

Error message

Failed to find a Lighthouse report (*${GithubApi.LH_JSON_EXT}) in gist ${id}

What it means

Thrown by GithubApi.getGistFileContentAsJson after a successful gist fetch when none of the gist's files match the Lighthouse report extension (*.lighthouse.report.json) nor, as a fallback, end in '.json'. The viewer expects at least one JSON file to parse as a Lighthouse report; a gist containing only non-JSON files fails here.

Source

Thrown at viewer/app/src/github-api.js:144

              // Delete the entry from IDB if it no longer exists on the server.
              idbKeyval.delete(id); // Note: async.
            } else if (resp.status === 401 && accessToken) {
              this._auth.signOut();
            }
            throw new Error(`${resp.status} fetching gist`);
          }

          const etag = resp.headers.get('ETag');
          return resp.json().then(json => {
            const gistFiles = Object.keys(json.files);
            // Attempt to use first file in gist with report extension.
            let filename = gistFiles.find(filename => filename.endsWith(GithubApi.LH_JSON_EXT));
            // Otherwise, fall back to first json file in gist
            if (!filename) {
              filename = gistFiles.find(filename => filename.endsWith('.json'));
            }
            if (!filename) {
              throw new Error(
                `Failed to find a Lighthouse report (*${GithubApi.LH_JSON_EXT}) in gist ${id}`
              );
            }
            const f = json.files[filename];
            if (f.truncated) {
              return fetch(f.raw_url)
                .then(resp => resp.json())
                .then(content => ({etag, content}));
            }
            const lhr = /** @type {LH.Result} */ (JSON.parse(f.content));
            return {etag, content: lhr};
          });
        });
      });
    }).then(response => {
      // Cache the contents to speed up future lookups, even if an invalid
      // report. Future requests for the id will either still be invalid or will
      // not return a 304 and so will be overwritten.

View on GitHub (pinned to 9515cd4e58)

Solutions

  1. Use a gist that was created by the Lighthouse viewer (it names the file <prefix>.lighthouse.report.json).
  2. Verify the gist contains a *.lighthouse.report.json or at least a *.json file before attempting to load.
  3. Show the user that the gist has no loadable report file.

Example fix

// before
const lhr = await githubApi.getGistFileContentAsJson(id); // gist has no .json

// after
try {
  const lhr = await githubApi.getGistFileContentAsJson(id);
} catch (err) {
  if (err.message.includes('Failed to find a Lighthouse report')) {
    showMessage('This gist does not contain a Lighthouse report.');
  } else throw err;
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-check is not exposed; the gist contents are only known after fetch.
// Validate at the source: only load gist ids produced by the Lighthouse viewer.

Try / catch

try {
  const lhr = await githubApi.getGistFileContentAsJson(id);
} catch (err) {
  if (err.message.includes('Failed to find a Lighthouse report')) {
    showMessage('This gist does not contain a Lighthouse report file.');
  } else throw err;
}

Prevention

When it happens

Trigger: Loading a gist id whose files are all non-JSON (e.g. images, markdown) or a gist that was created manually/with wrong filenames rather than by the Lighthouse viewer.

Common situations: User pastes the wrong gist URL/id; gist was edited and files renamed; loading a gist that stores the report under an unexpected extension.

Related errors


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