{"record":{"id":"9ac1c3c3951a70a2","repo":"mui/material-ui","slug":"version-majorversion-does-not-have-version-defi","errorCode":null,"errorMessage":"Version ${majorVersion} does not have version defined for the ${packageName}","messagePattern":"Version (.+?) does not have version defined for the (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/useReactVersion.mjs","lineNumber":88,"sourceCode":"          throw new Error(`Could not find '${version}' in \"${versions}\"`);\n        }\n      } else {\n        packageVersion = tagMapping.replace(`${version}: `, '');\n      }\n\n      packageJson.resolutions[reactPackageName] = packageVersion;\n    }),\n  );\n\n  // At this moment all dist tags reference React 18 version, so we don't need\n  // to update these dependencies unless an older version is used, or when the\n  // next/experimental dist tag reference to a future version of React\n  // packageJson.devDependencies['@testing-library/react'] = 'alpha';\n\n  if (majorVersion && additionalVersionsMappings[majorVersion]) {\n    devDependenciesPackageNames.forEach((packageName) => {\n      if (!additionalVersionsMappings[majorVersion][packageName]) {\n        throw new Error(\n          `Version ${majorVersion} does not have version defined for the ${packageName}`,\n        );\n      }\n      packageJson.resolutions[packageName] = additionalVersionsMappings[majorVersion][packageName];\n    });\n  }\n\n  // add newline for clean diff\n  fs.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}${os.EOL}`);\n\n  console.log('Installing dependencies...');\n  const pnpmInstall = childProcess.spawn('pnpm', ['install', '--no-frozen-lockfile'], {\n    shell: true,\n    stdio: ['inherit', 'inherit', 'inherit'],\n  });\n  pnpmInstall.on('exit', (exitCode) => {\n    if (exitCode !== 0) {\n      throw new Error('Failed to install dependencies');","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/mui/material-ui/blob/bdc96df2cb530fcdd60a7a7aabe37f610ce0f0a5/scripts/useReactVersion.mjs#L70-L106","documentation":"Thrown when additionalVersionsMappings has an entry for the requested React major version but that entry is missing a version for one of the names in devDependenciesPackageNames. In the current source only React 17 is mapped and it covers `@testing-library/react`, so in practice this fires only when a maintainer adds a new major version (e.g. 18, 19) with an incomplete mapping, or extends devDependenciesPackageNames without backfilling every major version in additionalVersionsMappings. It is a config-completeness guard, not a user-input error.","triggerScenarios":"A maintainer adds `18: { }` (or a partial object) to additionalVersionsMappings and runs the script with a React 18 version; or adds a new entry like `@testing-library/react-hooks` to devDependenciesPackageNames without adding it under key 17. The forEach hits the missing combination and throws.","commonSituations":"Refactoring the dev-dep pin list; introducing support for a new React major in a hurry; copy-pasting a partial mapping from a PR; renaming a package in devDependenciesPackageNames but not in the mappings.","solutions":["Open scripts/useReactVersion.mjs and add the missing entry under additionalVersionsMappings[majorVersion] for the named package.","If the dev-dep should not be pinned per React version, remove it from devDependenciesPackageNames instead of adding a mapping.","After editing, re-run `node scripts/useReactVersion.mjs <version>` to confirm the matrix resolves cleanly."],"exampleFix":"// before\nconst additionalVersionsMappings = {\n  17: { '@testing-library/react': '^12.1.0' },\n};\n\n// after\nconst additionalVersionsMappings = {\n  17: { '@testing-library/react': '^12.1.0' },\n  18: { '@testing-library/react': '^13.4.0' },\n};","handlingStrategy":"validation","validationCode":"// Detect a partial additionalVersionsMappings entry before running the\n// script. Add this as a unit test in the repo so refactors fail fast.\nconst devDependenciesPackageNames = ['@testing-library/react'];\nconst additionalVersionsMappings: Record<number, Record<string, string>> = {\n  17: { '@testing-library/react': '^12.1.0' },\n};\n\nfunction assertMappingsComplete() {\n  for (const [major, mapping] of Object.entries(additionalVersionsMappings)) {\n    for (const dep of devDependenciesPackageNames) {\n      if (typeof mapping[dep] !== 'string') {\n        throw new Error(\n          `additionalVersionsMappings[${major}] is missing entry for \"${dep}\".`,\n        );\n      }\n    }\n  }\n}","typeGuard":"// Narrows a major-version mapping to one that covers every dev dep.\nfunction isCompleteMapping(\n  mapping: unknown,\n  required: readonly string[],\n): mapping is Record<string, string> {\n  if (typeof mapping !== 'object' || mapping === null) return false;\n  const m = mapping as Record<string, unknown>;\n  return required.every((name) => typeof m[name] === 'string' && m[name].length > 0);\n}","tryCatchPattern":"// When extending the script with a new React major, wrap the run so the\n// missing-mapping error points at the file/line that needs editing.\ntry {\n  await main(version);\n} catch (err) {\n  if (err instanceof Error && /does not have version defined for the/.test(err.message)) {\n    throw new Error(\n      `${err.message} Update additionalVersionsMappings in scripts/useReactVersion.mjs, ` +\n      `or remove the package from devDependenciesPackageNames.`,\n    );\n  }\n  throw err;\n}","preventionTips":["Treat additionalVersionsMappings and devDependenciesPackageNames as a paired schema — add a unit test that asserts completeness.","When adding a new React major, copy an existing entry and edit every value, do not start from an empty object.","When adding a new dev-dep name, backfill it under every existing major key in the same commit.","Run the script locally with the new major version before pushing the CI change."],"tags":["react","dependency-matrix","config","maintainer","dev-dependencies"],"backgroundTag":null,"analyzedSha":"bdc96df2cb530fcdd60a7a7aabe37f610ce0f0a5","analyzedAt":"2026-08-12T22:59:56.717Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}