{"record":{"id":"48beb09c478352fa","repo":"GoogleChrome/lighthouse","slug":"usage-0-computed-file","errorCode":null,"errorMessage":"Usage $0 <computed file>","messagePattern":"Usage \\$0 <computed file>","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/scripts/lantern/assert-baseline-lantern-values-unchanged.js","lineNumber":23,"sourceCode":" * SPDX-License-Identifier: Apache-2.0\n */\n\nimport fs from 'fs';\nimport assert from 'assert/strict';\nimport path from 'path';\n\nimport chalk from 'chalk';\n\nimport constants from './constants.js';\nimport {readJson} from '../../test/test-utils.js';\n\nconst INPUT_PATH = process.argv[2] || constants.SITE_INDEX_WITH_GOLDEN_WITH_COMPUTED_PATH;\nconst HEAD_PATH = path.resolve(process.cwd(), INPUT_PATH);\nconst BASELINE_PATH = constants.BASELINE_COMPUTED_PATH;\nconst BASELINE_ACCURACY_PATH = constants.BASELINE_ACCURACY_PATH;\n\nif (!fs.existsSync(HEAD_PATH) || !fs.existsSync(BASELINE_PATH)) {\n  throw new Error('Usage $0 <computed file>');\n}\n\nconst computedResults = readJson(HEAD_PATH);\nconst expectedResults = readJson(BASELINE_PATH);\n\n/** @type {Array<{url: string, maxDiff: number, diffsForSite: Array<DiffForSite>}>} */\nconst diffs = [];\nfor (const entry of computedResults.sites) {\n  // @ts-expect-error - over-aggressive implicit any on candidate\n  const expectedLantern = expectedResults.sites.find(candidate => entry.url === candidate.url);\n  const actualLantern = entry.lantern;\n\n  let maxDiff = 0;\n  /** @type {DiffForSite[]} */\n  const diffsForSite = [];\n  Object.keys(actualLantern).forEach(metricName => {\n    if (!(metricName in expectedLantern)) throw new Error(`missing metric ${metricName}`);\n","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/GoogleChrome/lighthouse/blob/9515cd4e58ebed69f78742d932b501c2cab8ad8f/core/scripts/lantern/assert-baseline-lantern-values-unchanged.js#L5-L41","documentation":"Thrown at the top level of assert-baseline-lantern-values-unchanged.js when either the HEAD computed-results file (INPUT_PATH) or the BASELINE_COMPUTED_PATH does not exist on disk. The script compares current Lantern metric values against a checked-in baseline, so both files must be present.","triggerScenarios":"Running the baseline assertion script before generating the computed results file, or before the baseline has been created; passing a wrong path argument.","commonSituations":"Running the script on a fresh checkout without building results first; CI job ordering wrong (assertion before generation); typo in the path argument.","solutions":["Run the Lantern collection/computation step first to produce the computed results JSON at INPUT_PATH.","Verify BASELINE_COMPUTED_PATH (from constants.js) exists in the repo; if missing, regenerate or restore from git.","Pass the correct computed-file path as the first argument, or omit it to use the default."],"exampleFix":"// before\nnode core/scripts/lantern/assert-baseline-lantern-values-unchanged.js wrong-path.json\n// after\nnpm run lantern-collect && node core/scripts/lantern/assert-baseline-lantern-values-unchanged.js","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nfunction assertInputsExist(headPath, baselinePath) {\n  if (!fs.existsSync(headPath) || !fs.existsSync(baselinePath)) {\n    console.error('Usage: $0 <computed file>');\n    process.exit(1);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run the computation/generation step before the assertion script.","Verify the baseline file is present in the repo (git checkout if missing).","Pass the correct path argument or rely on the default constant."],"tags":["lantern","baseline","filesystem","cli-usage","assertion"],"backgroundTag":null,"analyzedSha":"9515cd4e58ebed69f78742d932b501c2cab8ad8f","analyzedAt":"2026-08-13T06:28:10.346Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}