{"record":{"id":"e89026847888c192","repo":"facebook/docusaurus","slug":"the-versions-file-should-contain-an-array-of-versi","errorCode":null,"errorMessage":"The versions file should contain an array of version names! Found content: ${JSON.stringify(names)}","messagePattern":"The versions file should contain an array of version names! Found content: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/docusaurus-plugin-content-docs/src/versions/validation.ts","lineNumber":45,"sourceCode":"    // eslint-disable-next-line no-control-regex\n    [/[<>:\"|?*\\x00-\\x1F]/, 'should be a valid file path'],\n    [/^\\.\\.?$/, 'should not be \".\" or \"..\"'],\n  ];\n\n  errors.forEach(([pattern, message]) => {\n    if (pattern.test(name)) {\n      throw new Error(\n        `Invalid version name \"${name}\": version name ${message}.`,\n      );\n    }\n  });\n}\n\nexport function validateVersionNames(\n  names: unknown,\n): asserts names is string[] {\n  if (!Array.isArray(names)) {\n    throw new Error(\n      `The versions file should contain an array of version names! Found content: ${JSON.stringify(\n        names,\n      )}`,\n    );\n  }\n\n  names.forEach(validateVersionName);\n}\n\n/**\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[],","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/facebook/docusaurus/blob/3f483e80e326cc646b54b83d564b3f0c4881b9a6/packages/docusaurus-plugin-content-docs/src/versions/validation.ts#L27-L63","documentation":"Thrown by validateVersionNames() before iterating entries. The function expects versions.json to deserialize to a JSON array; if the top-level value is anything else (an object, a string, a number, null), the build fails with a JSON dump of the offending content. Each element of the (valid) array is then passed to validateVersionName.","triggerScenarios":"versions.json is an object like {\"1.4\": {...}} instead of an array; the file contains a bare string or number at the top level; the file is null or corrupted JSON that parsed to a non-array; a tool wrote key/value pairs instead of a list.","commonSituations":"Hand-editing versions.json into a map; merging configs; copy-paste from a different format; corrupted write.","solutions":["Rewrite versions.json as a JSON array of version-name strings, e.g. [\"1.4\", \"1.3\"].","If you need per-version config, that goes in docusaurus.config.js under docs.versions, NOT in versions.json.","Validate the file parses to Array.isArray(...) before committing."],"exampleFix":"// versions.json - before (object)\n{\"1.4\": {}, \"1.3\": {}}\n\n// after (flat string array)\n[\"1.4\", \"1.3\"]","handlingStrategy":"type-guard","validationCode":"const fs = require('fs');\nfunction validateVersionsJsonIsArray(filePath) {\n  const json = JSON.parse(fs.readFileSync(filePath, 'utf8'));\n  if (!Array.isArray(json)) {\n    throw new Error(`versions.json must be a JSON array of strings, got ${typeof json}`);\n  }\n}","typeGuard":"function isStringArray(value) {\n  return Array.isArray(value) && value.every((v) => typeof v === 'string');\n}","tryCatchPattern":null,"preventionTips":["Keep versions.json as a flat JSON array of strings only.","Put per-version config in docusaurus.config.js (docs.versions), not in versions.json.","Add a JSON-schema check in CI to enforce the array-of-strings shape."],"tags":["docs","versioning","configuration","validation"],"backgroundTag":null,"analyzedSha":"3f483e80e326cc646b54b83d564b3f0c4881b9a6","analyzedAt":"2026-08-12T13:25:04.382Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}