{"record":{"id":"c83c89ed97221ce0","repo":"facebook/docusaurus","slug":"invalid-docs-option-onlyincludeversions-an-empt","errorCode":null,"errorMessage":"Invalid docs option \"onlyIncludeVersions\": an empty array is not allowed, at least one version is needed.","messagePattern":"Invalid docs option \"onlyIncludeVersions\": an empty array is not allowed, at least one version is needed\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/docusaurus-plugin-content-docs/src/versions/validation.ts","lineNumber":91,"sourceCode":"    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(\n        `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    ) {","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/facebook/docusaurus/blob/3f483e80e326cc646b54b83d564b3f0c4881b9a6/packages/docusaurus-plugin-content-docs/src/versions/validation.ts#L73-L109","documentation":"Thrown by validateVersionsOptions when docs.onlyIncludeVersions is provided as an array but is empty. onlyIncludeVersions filters which versions are built; an empty filter would build nothing, so the plugin rejects it to fail fast. At least one version name is required.","triggerScenarios":"Setting onlyIncludeVersions: [] in docs options, or programmatically building the array from a filter that yields no values.","commonSituations":"Dynamically computing onlyIncludeVersions (e.g. from an env var or CI matrix) and the source list being empty; refactoring that leaves a placeholder empty array; misconfigured partial builds.","solutions":["Populate onlyIncludeVersions with at least one valid version name from the available list.","If you want all versions, omit onlyIncludeVersions entirely instead of passing [].","Guard dynamic arrays: only set it when length > 0."],"exampleFix":"// before\ndocs: { onlyIncludeVersions: [] }\n// after\ndocs: { onlyIncludeVersions: ['current', '1.0'] }\n// or simply omit it\ndocs: {}","handlingStrategy":"validation","validationCode":"if (Array.isArray(config.onlyIncludeVersions) && config.onlyIncludeVersions.length === 0) {\n  throw new Error('onlyIncludeVersions must not be empty');\n}","typeGuard":"const isNonEmptyStringArray = (v: unknown): v is string[] =>\n  Array.isArray(v) && v.length > 0 && v.every(x => typeof x === 'string');","tryCatchPattern":null,"preventionTips":["When computing onlyIncludeVersions dynamically, fall back to undefined (all versions) when the list is empty.","Unit-test config generators for the empty-list edge case."],"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"}