badges/shields · error · InvalidResponse
version not found
Error message
version not found
What it means
Thrown in GemDownloadsService.fetchDownloadCountForVersion when the RubyGems API response for a gem contains no version entry whose number equals the requested version. The service searches the versions JSON for number === wantedVersion and raises InvalidResponse 'version not found' if no element matches.
Source
Thrown at services/gem/gem-downloads.service.js:104
},
})
let wantedVersion
if (version === 'stable') {
wantedVersion = latestVersion(
json
.filter(({ prerelease }) => !prerelease)
.map(({ number }) => number),
)
} else {
wantedVersion = version
}
const versionData = json.find(({ number }) => number === wantedVersion)
if (versionData) {
return versionData.downloads_count
} else {
throw new InvalidResponse({
prettyMessage: 'version not found',
})
}
}
async fetchDownloadCountForGem({ gem }) {
const { downloads: totalDownloads, version_downloads: versionDownloads } =
await this._requestJson({
url: `https://rubygems.org/api/v1/gems/${gem}.json`,
schema: gemSchema,
httpErrors: {
404: 'gem not found',
},
})
return { totalDownloads, versionDownloads }
}
async handle({ variant, gem, version }) {View on GitHub (pinned to 766fd8bc89)
Solutions
- Check the exact published version with `gem list -r <gem> -a` or rubygems.org/gems/<gem>/versions
- Remove the leading 'v' from the badge URL — RubyGems version numbers have no prefix
- Verify the version is not yanked; use a released version
- If using 'stable', confirm the gem has a stable (non-prerelease) version
Example fix
// before /gem/dv/mygem/v1.2.3 // after /gem/dv/mygem/1.2.3
Defensive patterns
Strategy: validation
Validate before calling
const versions = await fetch(`https://rubygems.org/api/v1/versions/${gem}.json`).then(r => r.json());const exists = versions.some(v => v.number === wantedVersion);if (!exists) console.warn(`${gem} has no version ${wantedVersion}`); Type guard
const hasVersion = (list, v) => Array.isArray(list) && list.some(e => e?.number === v);
Try / catch
try { count = await getGemDownloads(gem, version); } catch (e) { if (String(e.message).includes('version not found')) { count = await getGemDownloads(gem, 'stable'); } else { throw e; } } Prevention
- Use exact RubyGems version strings without a 'v' prefix
- Check rubygems.org versions page before hardcoding a version
- Avoid referencing yanked or pre-release versions in badges
When it happens
Trigger: Requesting a downloads badge with a specific version (dv variant) that the gem has never published, e.g. /gem/dv/rails/99.9.9, or when 'stable' resolved to a version that is absent from the returned payload.
Common situations: Typo in the version string (missing patch segment, extra 'v' prefix like v2.3.1); querying a gem after its versions were yanked; badge cached with a pre-release that was later deleted.
Related errors
AI-assisted analysis of badges/shields@766fd8bc89 (2026-08-30).
Data as JSON: /api/errors/3a77c12477b7be09.
Report an issue: GitHub.