{"record":{"id":"bf8ba6a46952004a","repo":"vitest-dev/vitest","slug":"failed-to-update-coverage-thresholds-configuratio","errorCode":null,"errorMessage":"Failed to update coverage thresholds. Configuration file is too complex.","messagePattern":"Failed to update coverage thresholds\\. Configuration file is too complex\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/vitest/src/node/coverage.ts","lineNumber":903,"sourceCode":"    let config = resolveDefineConfig(mod)\n    if (config) {\n      return config\n    }\n\n    // \"export default mergeConfig(..., defineConfig(...))\"\n    if (mod.$type === 'function-call' && mod.$callee === 'mergeConfig') {\n      config = resolveMergeConfig(mod)\n      if (config) {\n        return config\n      }\n    }\n  }\n  catch (error) {\n    // Reduce magicast's verbose errors to readable ones\n    throw new Error(error instanceof Error ? error.message : String(error))\n  }\n\n  throw new Error(\n    'Failed to update coverage thresholds. Configuration file is too complex.',\n  )\n}\n\nfunction resolveDefineConfig(mod: any) {\n  if (mod.$type === 'function-call' && mod.$callee === 'defineConfig') {\n    // \"export default defineConfig({ test: {...} })\"\n    if (mod.$args[0].$type === 'object') {\n      return mod.$args[0]\n    }\n\n    if (mod.$args[0].$type === 'arrow-function-expression') {\n      if (mod.$args[0].$body.$type === 'object') {\n        // \"export default defineConfig(() => ({ test: {...} }))\"\n        return mod.$args[0].$body\n      }\n\n      // \"export default defineConfig(() => mergeConfig({...}, ...))\"","sourceCodeStart":885,"sourceCodeEnd":921,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/vitest/src/node/coverage.ts#L885-L921","documentation":"Final fallback in resolveConfig: none of the recognized config shapes matched (plain object, defineConfig call with object/arrow body, mergeConfig call). autoUpdate cannot statically rewrite thresholds, so it reports the config is too complex.","triggerScenarios":"autoUpdate on a config whose default export is neither a literal object, a defineConfig(...), nor a mergeConfig(...) — e.g. a bare function, a re-export, a class instance, or a conditional expression.","commonSituations":"Configs like `export default condition ? a : b`; configs wrapped in custom helpers; configs that re-export from another module.","solutions":["Restructure the default export to defineConfig({ test: { coverage: { thresholds } } }).","Disable coverage.thresholds.autoUpdate and update thresholds manually.","Use mergeConfig to layer configs (it is one of the recognized shapes)."],"exampleFix":"// before\nexport default buildConfig(env) // custom helper\n\n// after\nexport default defineConfig({\n  test: { coverage: { thresholds: { lines: 80 } } }\n})","handlingStrategy":"fallback","validationCode":"function configShapeSupported(mod) {\n  if (mod.$type === 'object') return true\n  if (mod.$type === 'function-call' && (mod.$callee === 'defineConfig' || mod.$callee === 'mergeConfig')) return true\n  return false\n}\n// before autoUpdate: if (!configShapeSupported(parsed)) fall back to manual threshold update","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Restructure the default export to defineConfig({ test: { coverage: { thresholds } } }).","Disable autoUpdate for configs that can't be statically rewritten; update thresholds manually.","Use mergeConfig to compose layered configs."],"tags":["coverage","thresholds","config-structure"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}