{"record":{"id":"7b6990a2f2466c01","repo":"GoogleChrome/lighthouse","slug":"missing-wpt-key","errorCode":null,"errorMessage":"missing WPT_KEY","messagePattern":"missing WPT_KEY","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/scripts/lantern/collect/collect.js","lineNumber":57,"sourceCode":"  fs.writeFileSync(`${common.collectFolder}/${filename}`, data);\n  return filename;\n}\n\n/**\n * @param {string} url\n * @return {Promise<string>}\n */\nasync function fetchString(url) {\n  const response = await fetch(url);\n  if (response.ok) return response.text();\n  throw new Error(`error fetching ${url}: ${response.status} ${response.statusText}`);\n}\n\n/**\n * @param {string} url\n */\nasync function startWptTest(url) {\n  if (!WPT_KEY) throw new Error('missing WPT_KEY');\n\n  const apiUrl = new URL('/runtest.php', WPT_URL);\n  apiUrl.search = new URLSearchParams({\n    k: WPT_KEY,\n    f: 'json',\n    url,\n    location: 'gce-us-east4-linux:Chrome.3GFast',\n    runs: '1',\n    lighthouse: '1',\n    mobile: '1',\n    // Make the trace file available over /getgzip.php.\n    lighthouseTrace: '1',\n    lighthouseScreenshots: '1',\n    // Disable some things that WPT does, such as a \"repeat view\" analysis.\n    type: 'lighthouse',\n  }).toString();\n  const wptResponseJson = await fetchString(apiUrl.href);\n  const wptResponse = JSON.parse(wptResponseJson);","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/GoogleChrome/lighthouse/blob/9515cd4e58ebed69f78742d932b501c2cab8ad8f/core/scripts/lantern/collect/collect.js#L39-L75","documentation":"Thrown by startWptTest() when the WPT_KEY environment variable is falsy. WebPageTest requires an API key to start tests, so the script refuses to proceed without one.","triggerScenarios":"Running the Lantern collect script without setting WPT_KEY; the variable is set in a different shell or .env file not loaded.","commonSituations":"Fresh environment without WPT credentials; .env file not sourced; CI secret not injected.","solutions":["Obtain a WPT API key from webpagetest.org and set `export WPT_KEY=your_key` before running.","If using a .env file, ensure it's loaded (e.g. via dotenv) before the script runs.","In CI, add WPT_KEY as a secret environment variable."],"exampleFix":"// before\nnode core/scripts/lantern/collect/collect.js\n// after\nexport WPT_KEY=YOUR_KEY && node core/scripts/lantern/collect/collect.js","handlingStrategy":"validation","validationCode":"if (!process.env.WPT_KEY) {\n  console.error('Missing WPT_KEY. Set it via: export WPT_KEY=your_key');\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Store WPT_KEY in a .env file or shell profile.","Add a startup check that validates required env vars before any work begins.","In CI, inject WPT_KEY as a secret."],"tags":["wpt","env","api-key","config","lantern"],"backgroundTag":null,"analyzedSha":"9515cd4e58ebed69f78742d932b501c2cab8ad8f","analyzedAt":"2026-08-13T06:28:10.346Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}