{"record":{"id":"f6c3d43c8bcce5de","repo":"badges/shields","slug":"recent-downloads-not-supported-for-specific-versio","errorCode":null,"errorMessage":"recent downloads not supported for specific versions","messagePattern":"recent downloads not supported for specific versions","errorType":"validation","errorClass":"InvalidParameter","httpStatus":400,"severity":"error","filePath":"services/crates/crates-downloads.service.js","lineNumber":91,"sourceCode":"  }\n\n  transform({ variant, json }) {\n    switch (variant) {\n      case 'dv':\n        return this.constructor.getVersionObj(json).downloads\n      case 'dr':\n        return json.crate.recent_downloads || 0\n      default:\n        return json.crate ? json.crate.downloads : json.version.downloads\n    }\n  }\n\n  async handle({ variant, crate, version }) {\n    if (variant === 'dr' && version) {\n      /* crates.io doesn't currently expose\n         recent download counts for individual\n         versions */\n      throw new InvalidParameter({\n        prettyMessage: 'recent downloads not supported for specific versions',\n      })\n    }\n\n    const json = await this.fetch({ crate, version })\n\n    const downloads = this.transform({ variant, json })\n\n    return this.constructor.render({ variant, downloads, version })\n  }\n}\n","sourceCodeStart":73,"sourceCodeEnd":103,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/crates/crates-downloads.service.js#L73-L103","documentation":"The crates downloads service supports two variants; the 'dr' (recent downloads) variant only works for whole crates. crates.io does not expose recent download counts per version, so requesting dr with a version parameter throws InvalidParameter before any fetch.","triggerScenarios":"Calling the downloads badge with variant 'dr' AND a version segment, e.g. /crates/dr/<crate>/<version>.","commonSituations":"Users appending a version out of habit from the 'dv' (total downloads per version) badge, or copy-pasting a URL template and swapping variant letters.","solutions":["Drop the version segment: /crates/dr/<crate> for recent downloads of the whole crate","Use the 'dv' variant instead: /crates/dv/<crate>/<version> for total downloads of a specific version","Update any saved badge URLs or documentation referencing dr with a version"],"exampleFix":"// before\n/badge/crates/dr/serde/1.0.0\n// after\n/badge/crates/dr/serde","handlingStrategy":"validation","validationCode":"if (variant === 'dr' && version) throw new Error('recent downloads (dr) cannot be scoped to a version; use variant dv for per-version totals');","typeGuard":null,"tryCatchPattern":"try {\n  const badge = await fetchBadge(`/crates/${variant}/${crate}${version ? `/${version}` : ''}`);\n} catch (e) {\n  if (e.message.includes('recent downloads not supported')) console.warn('use /crates/dv/<crate>/<version> for per-version downloads');\n  else throw e;\n}","preventionTips":["Use dr without a version for recent downloads of the whole crate","Use dv with a version for per-version total downloads","Never mix the dr variant with a version segment in saved URLs or docs"],"tags":["invalid-parameter","crates-io","badges"],"backgroundTag":"invalid-parameter","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}