{"record":{"id":"b3dfcc10de7eadd6","repo":"facebook/docusaurus","slug":"versions-should-be-strings-found-type-typeof-n","errorCode":null,"errorMessage":"Versions should be strings. Found type \"${typeof name}\" for version ${JSON.stringify(name)}.","messagePattern":"Versions should be strings\\. Found type \"(.+?)\" for version (.+?)\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/docusaurus-plugin-content-docs/src/versions/validation.ts","lineNumber":13,"sourceCode":"/**\n * Copyright (c) Facebook, Inc. and its affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport _ from 'lodash';\nimport type {VersionsOptions} from '@docusaurus/plugin-content-docs';\n\nexport function validateVersionName(name: unknown): asserts name is string {\n  if (typeof name !== 'string') {\n    throw new Error(\n      `Versions should be strings. Found type \"${typeof name}\" for version ${JSON.stringify(\n        name,\n      )}.`,\n    );\n  }\n  if (!name.trim()) {\n    throw new Error(\n      `Invalid version name \"${name}\": version name must contain at least one non-whitespace character.`,\n    );\n  }\n  const errors: [RegExp, string][] = [\n    [/[/\\\\]/, 'should not include slash (/) or backslash (\\\\)'],\n    [/.{33,}/, 'cannot be longer than 32 characters'],\n    // eslint-disable-next-line no-control-regex\n    [/[<>:\"|?*\\x00-\\x1F]/, 'should be a valid file path'],\n    [/^\\.\\.?$/, 'should not be \".\" or \"..\"'],\n  ];\n","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/facebook/docusaurus/blob/3f483e80e326cc646b54b83d564b3f0c4881b9a6/packages/docusaurus-plugin-content-docs/src/versions/validation.ts#L1-L31","documentation":"Thrown by validateVersionName() (an `asserts name is string` guard). The function is called for each entry in versions.json. If an entry is not of type string (e.g. a number, boolean, object, or null), the build fails with the found type and a JSON dump of the value. This is the first of three sequential checks inside validateVersionName (type, non-empty, regex rules).","triggerScenarios":"versions.json contains a numeric version like [1.4] instead of ['1.4']; a value is null or a boolean; the file was hand-edited and a key/value pair was inverted; a tool wrote version names as numbers.","commonSituations":"JSON authoring mistake (unquoted numbers); programmatic generation of versions.json without string coercion; corrupted or partially-merged versions.json.","solutions":["Edit versions.json so every entry is a JSON string, e.g. ['1.4', '1.3'] not [1.4, 1.3].","If generating versions.json programmatically, coerce each name with String(name) before writing.","Validate the JSON shape before committing (it must be a flat array of strings)."],"exampleFix":"// versions.json - before\n[1.4, 1.3]\n\n// after\n[\"1.4\", \"1.3\"]","handlingStrategy":"type-guard","validationCode":"const fs = require('fs');\nfunction validateVersionsJsonTypes(filePath) {\n  const json = JSON.parse(fs.readFileSync(filePath, 'utf8'));\n  json.forEach((name, i) => {\n    if (typeof name !== 'string') {\n      throw new Error(`versions.json[${i}] is ${typeof name}, expected string: ${JSON.stringify(name)}`);\n    }\n  });\n}","typeGuard":"function isStringArray(value) {\n  return Array.isArray(value) && value.every((v) => typeof v === 'string');\n}","tryCatchPattern":null,"preventionTips":["Quote all version names in versions.json (JSON strings, not numbers).","Coerce with String(name) when generating versions.json programmatically.","Lint versions.json with a JSON schema requiring string array items."],"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"}