facebook/docusaurus · error · Error

Invalid docs option "lastVersion": if you use both the "only

Error message

Invalid docs option "lastVersion": if you use both the "onlyIncludeVersions" and "lastVersion" options, then "lastVersion" must be present in the provided "onlyIncludeVersions" array.

What it means

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.

Source

Thrown at packages/docusaurus-plugin-content-docs/src/versions/validation.ts:110

        `Invalid docs option "onlyIncludeVersions": an empty array is not allowed, at least one version is needed.`,
      );
    }
    const unknownOnlyIncludeVersionNames = _.difference(
      options.onlyIncludeVersions,
      availableVersionNames,
    );
    if (unknownOnlyIncludeVersionNames.length > 0) {
      throw new Error(
        `Invalid docs option "onlyIncludeVersions": unknown versions (${unknownOnlyIncludeVersionNames.join(
          ',',
        )}) found. ${availableVersionNamesMsg}`,
      );
    }
    if (
      options.lastVersion &&
      !options.onlyIncludeVersions.includes(options.lastVersion)
    ) {
      throw new Error(
        `Invalid docs option "lastVersion": if you use both the "onlyIncludeVersions" and "lastVersion" options, then "lastVersion" must be present in the provided "onlyIncludeVersions" array.`,
      );
    }
  }
}

View on GitHub (pinned to 3f483e80e3)

Solutions

  1. Add the lastVersion value into the onlyIncludeVersions array.
  2. Or change lastVersion to a version that is already in onlyIncludeVersions.
  3. Or remove lastVersion to let the plugin infer the latest included version.

Example fix

// before
docs: {
  lastVersion: '1.0',
  onlyIncludeVersions: ['current'],
}
// after
docs: {
  lastVersion: 'current',
  onlyIncludeVersions: ['current'],
}
Defensive patterns

Strategy: validation

Validate before calling

if (config.onlyIncludeVersions && config.lastVersion && !config.onlyIncludeVersions.includes(config.lastVersion)) {
  throw new Error('lastVersion must be in onlyIncludeVersions');
}

Prevention

When it happens

Trigger: Setting onlyIncludeVersions: ['current'] while lastVersion: '1.0', or any case where lastVersion is filtered out.

Common situations: Tightening onlyIncludeVersions for a partial build (e.g. preview only latest) and forgetting to drop/adjust lastVersion; CI matrix builds that filter versions independently.

Related errors


AI-assisted analysis of facebook/docusaurus@3f483e80e3 (2026-08-12). Data as JSON: /api/errors/09b22e7de822f589. Report an issue: GitHub.