{"record":{"id":"d4dc5e0ac2871533","repo":"yarnpkg/yarn","slug":"package-0-doesn-t-have-a-1","errorCode":null,"errorMessage":"Package $0 doesn't have a $1.","messagePattern":"Package \\$0 doesn't have a \\$1\\.","errorType":"validation","errorClass":"MessageError","httpStatus":null,"severity":"error","filePath":"src/package-request.js","lineNumber":358,"sourceCode":"    // Now that we have all dependencies, it's safe to propagate optional\n    for (const otherRequest of ref.requests.slice(1)) {\n      ref.addOptional(otherRequest.optional);\n    }\n  }\n\n  /**\n   * TODO description\n   */\n\n  static validateVersionInfo(info: Manifest, reporter: Reporter) {\n    // human readable name to use in errors\n    const human = `${info.name}@${info.version}`;\n\n    info.version = PackageRequest.getPackageVersion(info);\n\n    for (const key of constants.REQUIRED_PACKAGE_KEYS) {\n      if (!info[key]) {\n        throw new MessageError(reporter.lang('missingRequiredPackageKey', human, key));\n      }\n    }\n  }\n\n  /**\n   * Returns the package version if present, else defaults to the uid\n   */\n\n  static getPackageVersion(info: Manifest): string {\n    // TODO possibly reconsider this behaviour\n    return info.version === undefined ? info._uid : info.version;\n  }\n\n  /**\n   * Gets all of the outdated packages and sorts them appropriately\n   */\n\n  static async getOutdatedPackages(","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/yarnpkg/yarn/blob/c2dda503f3759b5be5f0e24ecd9cf5c97a540147/src/package-request.js#L340-L376","documentation":"validateVersionInfo() iterates constants.REQUIRED_PACKAGE_KEYS (name and version) and throws if any key is falsy on the manifest. Yarn requires these keys for a structurally valid package definition before it can be added to the dependency graph.","triggerScenarios":"A fetched manifest (from any resolver source) is missing its name or version field. Called from find() via validateVersionInfo() right after version extraction.","commonSituations":"Hand-crafted or malformed packages on private registries; exotic/file/git resolvers returning incomplete manifests; registry proxies stripping fields.","solutions":["Inspect the source manifest of the failing package for missing name/version fields","Pin to a known-good published version of the dependency","Switch registry or mirror to one that serves complete packuments","If using a file: or link: resolver, ensure the referenced package.json has name and version"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import * as constants from './constants.js';\nfunction validateManifest(manifest) {\n  for (const key of constants.REQUIRED_PACKAGE_KEYS) {\n    if (!manifest[key]) {\n      return { valid: false, missing: key };\n    }\n  }\n  return { valid: true, missing: null };\n}","typeGuard":"function hasRequiredKeys(manifest: object, keys: string[]): boolean {\n  return keys.every(k => manifest[k] !== undefined && manifest[k] !== null && manifest[k] !== '');\n}","tryCatchPattern":"try {\n  PackageRequest.validateVersionInfo(info, reporter);\n} catch (e) {\n  if (e.message.includes(\"doesn't have a\")) {\n    // skip this manifest or fetch from an alternate source\n  }\n}","preventionTips":["Validate fetched manifests against REQUIRED_PACKAGE_KEYS before resolution","Avoid private registries that strip fields","Test file:/git: dependencies have complete package.json files"],"tags":["manifest","validation","package-keys"],"backgroundTag":null,"analyzedSha":"c2dda503f3759b5be5f0e24ecd9cf5c97a540147","analyzedAt":"2026-08-13T04:17:06.305Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}