{"record":{"id":"6801becbc45c8f17","repo":"GoogleChrome/lighthouse","slug":"invalid-precomputed-lantern-data-file","errorCode":null,"errorMessage":"Invalid precomputed lantern data file","messagePattern":"Invalid precomputed lantern data file","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/bin.js","lineNumber":104,"sourceCode":"  } else if (cliFlags.quiet) {\n    cliFlags.logLevel = 'silent';\n  }\n  log.setLevel(cliFlags.logLevel);\n\n  if (\n    cliFlags.output.length === 1 &&\n    cliFlags.output[0] === Printer.OutputMode.json &&\n    !cliFlags.outputPath\n  ) {\n    cliFlags.outputPath = 'stdout';\n  }\n\n  if (cliFlags.precomputedLanternDataPath) {\n    const lanternDataStr = fs.readFileSync(cliFlags.precomputedLanternDataPath, 'utf8');\n    /** @type {LH.PrecomputedLanternData} */\n    const data = JSON.parse(lanternDataStr);\n    if (!data.additionalRttByOrigin || !data.serverResponseTimeByOrigin) {\n      throw new Error('Invalid precomputed lantern data file');\n    }\n\n    cliFlags.precomputedLanternData = data;\n  }\n\n  if (!Array.isArray(cliFlags.chromeFlags)) {\n    cliFlags.chromeFlags = [cliFlags.chromeFlags];\n  }\n  cliFlags.chromeFlags.push('--enable-features=DevToolsWebMCPSupport');\n\n  // By default, cliFlags.enableErrorReporting is undefined so the user is\n  // prompted. This can be overridden with an explicit flag or by the cached\n  // answer returned by askPermission().\n  if (typeof cliFlags.enableErrorReporting === 'undefined') {\n    cliFlags.enableErrorReporting = await askPermission();\n  }\n  if (cliFlags.enableErrorReporting) {\n    await Sentry.init({","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/GoogleChrome/lighthouse/blob/9515cd4e58ebed69f78742d932b501c2cab8ad8f/cli/bin.js#L86-L122","documentation":"Lantern is Lighthouse's throttling-simulation engine. The --precomputed-lantern-data flag lets you supply pre-measured network round-trip times (additionalRttByOrigin) and server response times (serverResponseTimeByOrigin) as a JSON file so the simulator skips estimation. This error fires after JSON.parse succeeds but the resulting object lacks one or both required top-level keys, meaning the file is structurally a JSON object but semantically incomplete for Lantern.","triggerScenarios":"Passing --precomputed-lantern-data=path/to/file.json where the file is valid JSON but is missing the 'additionalRttByOrigin' key, the 'serverResponseTimeByOrigin' key, or both. Each key must be present and truthy (an object mapping origin strings to millisecond numbers).","commonSituations":"Using an outdated lantern data file from an older Lighthouse version with a different schema; hand-editing the JSON and accidentally removing a key; pointing the flag at the wrong JSON file (e.g., a Lighthouse report instead of a lantern data file); partial or truncated file export.","solutions":["Open the JSON file and confirm it has both 'additionalRttByOrigin' and 'serverResponseTimeByOrigin' keys, each containing an object like {\"https://example.com\": 123}","Regenerate the file using Lighthouse's lantern data collection (e.g., run with --throttling-method=simulate and extract the data, or use the devtools-lantern scripts in the Lighthouse repo)","Remove the --precomputed-lantern-data flag entirely to let Lantern estimate throttling values automatically"],"exampleFix":"// before (file contents):\n// {\"serverResponseTimeByOrigin\": {\"https://example.com\": 250}}\n// --precomputed-lantern-data=./lantern.json\n\n// after (file contents):\n// {\n//   \"additionalRttByOrigin\": {\"https://example.com\": 100},\n//   \"serverResponseTimeByOrigin\": {\"https://example.com\": 250}\n// }","handlingStrategy":"validation","validationCode":"// Validate lantern data file before passing to Lighthouse\nconst fs = require('fs');\nfunction validateLanternData(filePath) {\n  const raw = fs.readFileSync(filePath, 'utf8');\n  const data = JSON.parse(raw); // throws on invalid JSON\n  if (!data.additionalRttByOrigin || typeof data.additionalRttByOrigin !== 'object') {\n    throw new Error('Missing or invalid additionalRttByOrigin');\n  }\n  if (!data.serverResponseTimeByOrigin || typeof data.serverResponseTimeByOrigin !== 'object') {\n    throw new Error('Missing or invalid serverResponseTimeByOrigin');\n  }\n  return true;\n}","typeGuard":"/** @param {unknown} data */\nfunction isValidLanternData(data) {\n  if (typeof data !== 'object' || data === null) return false;\n  const d = /** @type {Record<string, unknown>} */ (data);\n  return typeof d.additionalRttByOrigin === 'object' && d.additionalRttByOrigin !== null &&\n         typeof d.serverResponseTimeByOrigin === 'object' && d.serverResponseTimeByOrigin !== null;\n}","tryCatchPattern":null,"preventionTips":["Always regenerate lantern data files when upgrading Lighthouse versions, as the schema may change","Keep lantern data files alongside the Lighthouse version that produced them","Validate the JSON structure programmatically before passing the file path to the CLI"],"tags":["cli","config","lantern","json","performance"],"backgroundTag":null,"analyzedSha":"9515cd4e58ebed69f78742d932b501c2cab8ad8f","analyzedAt":"2026-08-13T06:28:10.346Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}