{"record":{"id":"abbf0ead7e1dfe44","repo":"facebook/docusaurus","slug":"docs-option-lastversion-options-lastversion-is","errorCode":null,"errorMessage":"Docs option lastVersion: ${options.lastVersion} is invalid. ${availableVersionNamesMsg}","messagePattern":"Docs option lastVersion: (.+?) is invalid\\. (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/docusaurus-plugin-content-docs/src/versions/validation.ts","lineNumber":73,"sourceCode":"/**\n * @throws Throws for one of the following invalid options:\n * - `lastVersion` is non-existent\n * - `versions` includes unknown keys\n * - `onlyIncludeVersions` is empty, contains unknown names, or doesn't include\n * `latestVersion` (if provided)\n */\nexport function validateVersionsOptions(\n  availableVersionNames: string[],\n  options: VersionsOptions,\n): void {\n  const availableVersionNamesMsg = `Available version names are: ${availableVersionNames.join(\n    ', ',\n  )}`;\n  if (\n    options.lastVersion &&\n    !availableVersionNames.includes(options.lastVersion)\n  ) {\n    throw new Error(\n      `Docs option lastVersion: ${options.lastVersion} is invalid. ${availableVersionNamesMsg}`,\n    );\n  }\n  const unknownVersionConfigNames = _.difference(\n    Object.keys(options.versions),\n    availableVersionNames,\n  );\n  if (unknownVersionConfigNames.length > 0) {\n    throw new Error(\n      `Invalid docs option \"versions\": unknown versions (${unknownVersionConfigNames.join(\n        ',',\n      )}) found. ${availableVersionNamesMsg}`,\n    );\n  }\n\n  if (options.onlyIncludeVersions) {\n    if (options.onlyIncludeVersions.length === 0) {\n      throw new Error(","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/facebook/docusaurus/blob/3f483e80e326cc646b54b83d564b3f0c4881b9a6/packages/docusaurus-plugin-content-docs/src/versions/validation.ts#L55-L91","documentation":"Thrown by validateVersionsOptions in the docs plugin when the 'lastVersion' option references a version name that does not exist among the available version names (derived from versioned_docs/versions.json plus the current version). lastVersion determines which version is served at the docs root route, so it must resolve to a real version. The message lists the valid names to make the mismatch obvious.","triggerScenarios":"Setting docs.lastVersion to a string that is not in the availableVersionNames array (e.g. lastVersion:'2.0' when only ['current','1.0'] exist, or a typo like 'curent'). Triggered during option validation at build/dev startup of plugin-content-docs.","commonSituations":"Renaming a version in versions.json without updating lastVersion; cutting a new version (docusaurus docs:version) and forgetting to point lastVersion at it; copy-pasting a config from another project whose version names differ; typos after a major version bump.","solutions":["Read the error's 'Available version names are:' list and set lastVersion to one of those exact strings.","Open versions.json and confirm the version names; fix lastVersion in docusaurus.config.js docs options to match.","If you want the newest version served at root, you can often omit lastVersion entirely and let the plugin pick the latest.","After editing, rebuild (pnpm start / build) to re-run validation."],"exampleFix":"// before\ndocs: {\n  lastVersion: '2.0', // but versions.json only has current, 1.0\n}\n// after\ndocs: {\n  lastVersion: '1.0',\n}","handlingStrategy":"validation","validationCode":"import fs from 'fs';\nconst available = JSON.parse(fs.readFileSync('versions.json','utf8')); // string[]\nconst current = 'current';\nconst all = [...available, current];\nif (config.lastVersion && !all.includes(config.lastVersion)) {\n  throw new Error(`lastVersion ${config.lastVersion} not in ${all.join(', ')}`);\n}","typeGuard":"const isKnownVersion = (v: string, available: string[]): boolean =>\n  available.includes(v);","tryCatchPattern":null,"preventionTips":["Keep lastVersion in sync with versions.json via a single source of truth.","After every `docusaurus docs:version`, audit lastVersion and onlyIncludeVersions.","Lint docusaurus.config.js in CI to assert version refs exist in versions.json."],"tags":["docs","versioning","config-validation"],"backgroundTag":null,"analyzedSha":"3f483e80e326cc646b54b83d564b3f0c4881b9a6","analyzedAt":"2026-08-12T13:25:04.382Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}