{"record":{"id":"5bb4ea31305c4f35","repo":"GoogleChrome/lighthouse","slug":"expected-locale-file-to-exist-traceenginepath","errorCode":null,"errorMessage":"expected locale file to exist: ${traceEnginePath}","messagePattern":"expected locale file to exist: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/scripts/i18n/collect-strings.js","lineNumber":814,"sourceCode":"  const traceEngineStringsDir = `${LH_ROOT}/node_modules/@paulirish/trace_engine/locales`;\n  const lhStringsDir = `${LH_ROOT}/shared/localization/locales`;\n  for (const file of glob.sync(`${lhStringsDir}/*.json`)) {\n    let name = path.basename(file);\n    if (name.endsWith('.ctc.json')) {\n      continue;\n    }\n\n    if (name === 'ar-XB.json') {\n      name = 'ar.json';\n    }\n\n    if (['en-XA.json'].includes(name)) {\n      continue;\n    }\n\n    const traceEnginePath = `${traceEngineStringsDir}/${name}`;\n    if (!fs.existsSync(traceEnginePath)) {\n      throw new Error(`expected locale file to exist: ${traceEnginePath}`);\n    }\n\n    const traceEngineStrings = JSON.parse(fs.readFileSync(traceEnginePath, 'utf-8'));\n    const strings = JSON.parse(fs.readFileSync(file, 'utf-8'));\n    for (const [key, value] of Object.entries(traceEngineStrings)) {\n      const lhKey = `node_modules/@paulirish/trace_engine/${key.replace('.ts', '.js')}`;\n\n      // TODO: why is this so malformed? see b/399706272\n      if (['he.json', 'ru.json', 'ta.json'].includes(name) && lhKey === 'node_modules/@paulirish/trace_engine/generated/Deprecation.js | ObsoleteCreateImageBitmapImageOrientationNone') {\n        continue;\n      }\n\n      value.message = value.message\n        .replace(/\\\\\\\\/g, '')\n        .replace(`{imageOrientation: 'from-image'}`, `\\\\\\\\{imageOrientation: 'from-image'\\\\\\\\}`)\n        .replace(`{imageOrientation: ''from-image''}`, `\\\\\\\\{imageOrientation: ''from-image''\\\\\\\\}`)\n        .replace(`{imageOrientation: \"from-image\"}`, `\\\\\\\\{imageOrientation: \"from-image\"\\\\\\\\}`)\n        .replace(`{imageOrientation: 'from-image'\\\\}`, `\\\\\\\\{imageOrientation: 'from-image'\\\\\\\\}`)","sourceCodeStart":796,"sourceCodeEnd":832,"githubUrl":"https://github.com/GoogleChrome/lighthouse/blob/9515cd4e58ebed69f78742d932b501c2cab8ad8f/core/scripts/i18n/collect-strings.js#L796-L832","documentation":"Thrown during locale merging when a locale JSON file is expected to exist in the trace_engine strings directory but is missing on disk. The script iterates locale files and for each expects a corresponding trace_engine locale file; a missing one breaks the merge of trace_engine translations into Lighthouse's locale set.","triggerScenarios":"Running collect-strings (which produces and merges locale files) when the @paulirish/trace_engine dependency hasn't been fully installed, or when a locale exists in Lighthouse but not yet in trace_engine's generated output.","commonSituations":"Fresh checkout without `npm install` / `npm run build-all`; trace_engine version bump that removed or renamed a locale; adding a new locale to Lighthouse before trace_engine ships it.","solutions":["Run `npm install` and the relevant build steps to regenerate trace_engine locale files.","Check if the trace_engine package version in node_modules matches package.json expectations.","If the locale genuinely doesn't exist in trace_engine yet, add a skip/continue for that locale or wait for the upstream package update."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const fs = require('fs');\nconst path = require('path');\nfunction traceEngineLocaleExists(traceEngineStringsDir, name) {\n  return fs.existsSync(path.join(traceEngineStringsDir, name));\n}","typeGuard":null,"tryCatchPattern":"for (const file of localeFiles) {\n  const traceEnginePath = `${traceEngineStringsDir}/${name}`;\n  if (!fs.existsSync(traceEnginePath)) {\n    console.warn(`Skipping missing trace engine locale: ${traceEnginePath}`);\n    continue;\n  }\n  // ... proceed with merge\n}","preventionTips":["Run `npm install` and build steps before running collect-strings.","Keep the trace_engine dependency version in sync with what the script expects.","When adding a new Lighthouse locale, verify trace_engine ships it first."],"tags":["i18n","locale","trace-engine","dependency","filesystem"],"backgroundTag":null,"analyzedSha":"9515cd4e58ebed69f78742d932b501c2cab8ad8f","analyzedAt":"2026-08-13T06:28:10.346Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}