{"record":{"id":"957318b8eec34351","repo":"GoogleChrome/lighthouse","slug":"failed-to-find-a-lighthouse-report-githubapi-l","errorCode":null,"errorMessage":"Failed to find a Lighthouse report (*${GithubApi.LH_JSON_EXT}) in gist ${id}","messagePattern":"Failed to find a Lighthouse report \\(\\*(.+?)\\) in gist (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"viewer/app/src/github-api.js","lineNumber":144,"sourceCode":"              // Delete the entry from IDB if it no longer exists on the server.\n              idbKeyval.delete(id); // Note: async.\n            } else if (resp.status === 401 && accessToken) {\n              this._auth.signOut();\n            }\n            throw new Error(`${resp.status} fetching gist`);\n          }\n\n          const etag = resp.headers.get('ETag');\n          return resp.json().then(json => {\n            const gistFiles = Object.keys(json.files);\n            // Attempt to use first file in gist with report extension.\n            let filename = gistFiles.find(filename => filename.endsWith(GithubApi.LH_JSON_EXT));\n            // Otherwise, fall back to first json file in gist\n            if (!filename) {\n              filename = gistFiles.find(filename => filename.endsWith('.json'));\n            }\n            if (!filename) {\n              throw new Error(\n                `Failed to find a Lighthouse report (*${GithubApi.LH_JSON_EXT}) in gist ${id}`\n              );\n            }\n            const f = json.files[filename];\n            if (f.truncated) {\n              return fetch(f.raw_url)\n                .then(resp => resp.json())\n                .then(content => ({etag, content}));\n            }\n            const lhr = /** @type {LH.Result} */ (JSON.parse(f.content));\n            return {etag, content: lhr};\n          });\n        });\n      });\n    }).then(response => {\n      // Cache the contents to speed up future lookups, even if an invalid\n      // report. Future requests for the id will either still be invalid or will\n      // not return a 304 and so will be overwritten.","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/GoogleChrome/lighthouse/blob/9515cd4e58ebed69f78742d932b501c2cab8ad8f/viewer/app/src/github-api.js#L126-L162","documentation":"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.","triggerScenarios":"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.","commonSituations":"User pastes the wrong gist URL/id; gist was edited and files renamed; loading a gist that stores the report under an unexpected extension.","solutions":["Use a gist that was created by the Lighthouse viewer (it names the file <prefix>.lighthouse.report.json).","Verify the gist contains a *.lighthouse.report.json or at least a *.json file before attempting to load.","Show the user that the gist has no loadable report file."],"exampleFix":"// before\nconst lhr = await githubApi.getGistFileContentAsJson(id); // gist has no .json\n\n// after\ntry {\n  const lhr = await githubApi.getGistFileContentAsJson(id);\n} catch (err) {\n  if (err.message.includes('Failed to find a Lighthouse report')) {\n    showMessage('This gist does not contain a Lighthouse report.');\n  } else throw err;\n}","handlingStrategy":"try-catch","validationCode":"// Pre-check is not exposed; the gist contents are only known after fetch.\n// Validate at the source: only load gist ids produced by the Lighthouse viewer.","typeGuard":null,"tryCatchPattern":"try {\n  const lhr = await githubApi.getGistFileContentAsJson(id);\n} catch (err) {\n  if (err.message.includes('Failed to find a Lighthouse report')) {\n    showMessage('This gist does not contain a Lighthouse report file.');\n  } else throw err;\n}","preventionTips":["Only load gists created via the viewer (filename <prefix>.lighthouse.report.json).","When letting users paste a gist URL, expect some to be invalid; catch and message clearly.","If authoring gists manually, name the report file with the .lighthouse.report.json extension."],"tags":["github-api","gist","validation","file-format"],"backgroundTag":null,"analyzedSha":"9515cd4e58ebed69f78742d932b501c2cab8ad8f","analyzedAt":"2026-08-13T06:28:10.346Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}