{"record":{"id":"09b22e7de822f589","repo":"facebook/docusaurus","slug":"invalid-docs-option-lastversion-if-you-use-both","errorCode":null,"errorMessage":"Invalid docs option \"lastVersion\": if you use both the \"onlyIncludeVersions\" and \"lastVersion\" options, then \"lastVersion\" must be present in the provided \"onlyIncludeVersions\" array.","messagePattern":"Invalid docs option \"lastVersion\": if you use both the \"onlyIncludeVersions\" and \"lastVersion\" options, then \"lastVersion\" must be present in the provided \"onlyIncludeVersions\" array\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/docusaurus-plugin-content-docs/src/versions/validation.ts","lineNumber":110,"sourceCode":"        `Invalid docs option \"onlyIncludeVersions\": an empty array is not allowed, at least one version is needed.`,\n      );\n    }\n    const unknownOnlyIncludeVersionNames = _.difference(\n      options.onlyIncludeVersions,\n      availableVersionNames,\n    );\n    if (unknownOnlyIncludeVersionNames.length > 0) {\n      throw new Error(\n        `Invalid docs option \"onlyIncludeVersions\": unknown versions (${unknownOnlyIncludeVersionNames.join(\n          ',',\n        )}) found. ${availableVersionNamesMsg}`,\n      );\n    }\n    if (\n      options.lastVersion &&\n      !options.onlyIncludeVersions.includes(options.lastVersion)\n    ) {\n      throw new Error(\n        `Invalid docs option \"lastVersion\": if you use both the \"onlyIncludeVersions\" and \"lastVersion\" options, then \"lastVersion\" must be present in the provided \"onlyIncludeVersions\" array.`,\n      );\n    }\n  }\n}\n","sourceCodeStart":92,"sourceCodeEnd":116,"githubUrl":"https://github.com/facebook/docusaurus/blob/3f483e80e326cc646b54b83d564b3f0c4881b9a6/packages/docusaurus-plugin-content-docs/src/versions/validation.ts#L92-L116","documentation":"Thrown by validateVersionsOptions when both onlyIncludeVersions and lastVersion are set, but lastVersion is not a member of the onlyIncludeVersions array. Since onlyIncludeVersions restricts which versions are built, the version served at the root (lastVersion) must actually be among the built set; otherwise the root route would point to a non-rendered version.","triggerScenarios":"Setting onlyIncludeVersions: ['current'] while lastVersion: '1.0', or any case where lastVersion is filtered out.","commonSituations":"Tightening onlyIncludeVersions for a partial build (e.g. preview only latest) and forgetting to drop/adjust lastVersion; CI matrix builds that filter versions independently.","solutions":["Add the lastVersion value into the onlyIncludeVersions array.","Or change lastVersion to a version that is already in onlyIncludeVersions.","Or remove lastVersion to let the plugin infer the latest included version."],"exampleFix":"// before\ndocs: {\n  lastVersion: '1.0',\n  onlyIncludeVersions: ['current'],\n}\n// after\ndocs: {\n  lastVersion: 'current',\n  onlyIncludeVersions: ['current'],\n}","handlingStrategy":"validation","validationCode":"if (config.onlyIncludeVersions && config.lastVersion && !config.onlyIncludeVersions.includes(config.lastVersion)) {\n  throw new Error('lastVersion must be in onlyIncludeVersions');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When narrowing onlyIncludeVersions, re-derive lastVersion from the filtered set.","Treat onlyIncludeVersions and lastVersion as a single coupled config block."],"tags":["docs","versioning","config-validation"],"backgroundTag":null,"analyzedSha":"3f483e80e326cc646b54b83d564b3f0c4881b9a6","analyzedAt":"2026-08-12T13:25:04.382Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}