{"record":{"id":"dcf16dcb9bf48bb6","repo":"GoogleChrome/lighthouse","slug":"configpath-must-be-an-absolute-path","errorCode":null,"errorMessage":"configPath must be an absolute path","messagePattern":"configPath must be an absolute path","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"core/config/config.js","lineNumber":60,"sourceCode":" * The default priority should be 0.\n * TODO: Make this an official part of the config or design a different solution.\n * @type {Record<string, number|undefined>}\n */\nconst internalArtifactPriorities = {\n  FullPageScreenshot: 1,\n  BFCacheFailures: 1,\n};\n\n/**\n * @param {LH.Config|undefined} config\n * @param {{configPath?: string}} context\n * @return {{configWorkingCopy: LH.Config, configDir?: string, configPath?: string}}\n */\nfunction resolveWorkingCopy(config, context) {\n  let {configPath} = context;\n\n  if (configPath && !path.isAbsolute(configPath)) {\n    throw new Error('configPath must be an absolute path');\n  }\n\n  if (!config) {\n    config = defaultConfig;\n    configPath = defaultConfigPath;\n  }\n\n  // The directory of the config path, if one was provided.\n  const configDir = configPath ? path.dirname(configPath) : undefined;\n\n  return {\n    configWorkingCopy: deepCloneConfigJson(config),\n    configPath,\n    configDir,\n  };\n}\n\n/**","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/GoogleChrome/lighthouse/blob/9515cd4e58ebed69f78742d932b501c2cab8ad8f/core/config/config.js#L42-L78","documentation":"Thrown by resolveWorkingCopy in config.js. When you pass a configPath in the run context, it must be an absolute filesystem path (path.isAbsolute). Lighthouse needs an absolute path to resolve the config directory for relative audit/gatherer paths. A relative path like './my-config.js' is rejected.","triggerScenarios":"Calling flags.configPath = './lighthouse-config.js' or configPath: 'config/custom.js'. path.isAbsolute returns false, so config.js:60 throws. Common when building the path with a relative string instead of path.resolve(__dirname, ...).","commonSituations":"CLI/programmatic usage passing a relative config path. Reading configPath from user input or a relative env var. Cross-platform issues where a path that is absolute on one OS is treated as relative.","solutions":["Resolve to an absolute path before passing: configPath: path.resolve(process.cwd(), './my-config.js').","Use __dirname-relative resolution: path.resolve(__dirname, 'config.js').","If invoking the CLI, pass an absolute path or rely on the CLI to resolve it."],"exampleFix":"// before\nconst flags = {configPath: './config/my-config.js'};\nawait lighthouse(url, flags);\n// after\nconst path = require('path');\nconst flags = {configPath: path.resolve(__dirname, 'config/my-config.js')};\nawait lighthouse(url, flags);","handlingStrategy":"validation","validationCode":"const path = require('path');\nif (flags.configPath && !path.isAbsolute(flags.configPath)) {\n  flags.configPath = path.resolve(process.cwd(), flags.configPath);\n}","typeGuard":"const path = require('path');\nfunction isAbsolutePath(p) { return typeof p === 'string' && path.isAbsolute(p); }","tryCatchPattern":"try { await lighthouse(url, flags); }\ncatch (e) { if (/configPath must be an absolute path/.test(e.message)) flags.configPath = path.resolve(flags.configPath); throw e; }","preventionTips":["Always resolve config paths with path.resolve(__dirname, ...) or path.resolve(cwd, ...).","Treat user-supplied config paths as untrusted and resolve them."],"tags":["config","lighthouse","filesystem","paths"],"backgroundTag":null,"analyzedSha":"9515cd4e58ebed69f78742d932b501c2cab8ad8f","analyzedAt":"2026-08-13T06:28:10.346Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}