{"record":{"id":"ec9c2d9eccb496cc","repo":"vitest-dev/vitest","slug":"unable-to-parse-thresholds-from-configuration-file","errorCode":null,"errorMessage":"Unable to parse thresholds from configuration file: ${message}","messagePattern":"Unable to parse thresholds from configuration file: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/vitest/src/node/coverage.ts","lineNumber":869,"sourceCode":"  }\n}\n\nfunction assertConfigurationModule(config: unknown): asserts config is {\n  test: {\n    coverage: { thresholds: NonNullable<CoverageOptions['thresholds']> }\n  }\n} {\n  try {\n    // @ts-expect-error -- Intentional unsafe null pointer check as wrapped in try-catch\n    if (typeof config.test.coverage.thresholds !== 'object') {\n      throw new TypeError(\n        'Expected config.test.coverage.thresholds to be an object',\n      )\n    }\n  }\n  catch (error) {\n    const message = error instanceof Error ? error.message : String(error)\n    throw new Error(\n      `Unable to parse thresholds from configuration file: ${message}`,\n    )\n  }\n}\n\nfunction resolveConfig(configModule: any) {\n  const mod = configModule.exports.default\n\n  try {\n    // Check for \"export default { test: {...} }\"\n    if (mod.$type === 'object') {\n      return mod\n    }\n\n    // \"export default defineConfig(...)\"\n    let config = resolveDefineConfig(mod)\n    if (config) {\n      return config","sourceCodeStart":851,"sourceCodeEnd":887,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/vitest/src/node/coverage.ts#L851-L887","documentation":"Wrapper thrown by assertConfigurationModule when reading thresholds from the config file fails for any reason. It catches the inner TypeError (248) or any property-access exception and re-throws with a readable 'Unable to parse thresholds from configuration file' prefix, embedding the underlying message. Indicates the config module's shape does not match the expected {test:{coverage:{thresholds}}} structure.","triggerScenarios":"autoUpdate parsing a config where accessing config.test.coverage.thresholds throws — e.g. config is null/undefined, test is missing, or coverage is null, so the chained access throws and is caught here.","commonSituations":"Config file exporting something other than a Vitest config object; corrupted or partial config; thresholds referenced before being defined.","solutions":["Read the embedded ${message} to find the exact cause (it carries the inner error text).","Fix the config so config.test.coverage.thresholds resolves to an object.","Validate the config loads standalone (e.g. import it directly) before enabling autoUpdate."],"exampleFix":"// before\nexport default { plugins: [] } // no `test` key\n\n// after\nimport { defineConfig } from 'vitest/config'\nexport default defineConfig({\n  test: { coverage: { thresholds: { lines: 80 } } }\n})","handlingStrategy":"try-catch","validationCode":"async function canParseThresholds(configFilePath) {\n  try {\n    const mod = await import(configFilePath)\n    return mod?.default?.test?.coverage?.thresholds != null\n  } catch { return false }\n}","typeGuard":null,"tryCatchPattern":"try {\n  await vitest.reportCoverage(coverage, true) // triggers autoUpdate\n} catch (e) {\n  if (/Unable to parse thresholds/.test(e.message)) {\n    // read inner message, fix config.test.coverage.thresholds, retry\n  } else throw e\n}","preventionTips":["Validate that the config module exports { test: { coverage: { thresholds } } } before autoUpdate.","Import the config standalone to confirm it loads without error.","Surface the embedded inner message when reporting this error."],"tags":["coverage","thresholds","config-parse"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}