badges/shields · error · NotFound
invalid version
Error message
invalid version
What it means
This NotFound error is thrown by the Packagist dependency-version badge service when, after fetching a package's version data from the Packagist API, no packageVersion could be resolved for the requested version. The service tries to locate the requested release (or falls back through candidates); if every attempt yields nothing, it reports 'invalid version'.
Source
Thrown at services/packagist/packagist-dependency-version.service.js:102
if (version === '') {
packageVersion = this.findLatestRelease(versions)
} else {
try {
packageVersion = await this.findSpecifiedVersion(
versions,
user,
repo,
version,
server,
)
} catch (e) {
packageVersion = null
}
}
if (!packageVersion) {
throw new NotFound({ prettyMessage: 'invalid version' })
}
if (!packageVersion.require) {
throw new NotFound({ prettyMessage: 'version requirement not found' })
}
// All dependencies' names in the 'require' section from the response should be lowercase,
// so that we can compare lowercase name of the dependency given via url by the user.
Object.keys(packageVersion.require).forEach(dependency => {
packageVersion.require[dependency.toLowerCase()] =
packageVersion.require[dependency]
})
const depLowerCase = dependency.toLowerCase()
if (!packageVersion.require[depLowerCase]) {
throw new NotFound({ prettyMessage: 'version requirement not found' })
}View on GitHub (pinned to 766fd8bc89)
Solutions
- Check the exact version string in the badge URL against the releases listed on packagist.org for that package
- Remove or correct the version query parameter to use the latest release (omit the version part)
- If pinning a branch, verify the branch still exists on the source repository
- Re-run/rebadge after the package maintainer publishes the missing version
Example fix
// before /packagist/symfony/console/versio?version=dev-master-2.x // after /packagist/symfony/console/versio?version=v6.4.0
Defensive patterns
Strategy: validation
Validate before calling
const knownVersions = await getPackagistVersions(user, repo)
if (!knownVersions.includes(requestedVersion)) throw new Error(`Unknown version ${requestedVersion}; valid: ${knownVersions.join(', ')}`) Type guard
function isValidPackagistVersion(v) {
return typeof v === 'string' && (v === 'latest' || /^v?\d+(\.\d+)*(\.\d+)?([-.][\w.]+)?$/.test(v))
} Try / catch
try {
const { dependencyVersion } = await dependencyVersion(user, repo, dep, version)
} catch (e) {
if (e instanceof NotFound) console.warn(`Version '${version}' not found on Packagist; check packagist.org/${user}/${repo}`)
else throw e
} Prevention
- Validate the version string exists in the package's release list before building the badge
- Prefer omitting the version to track the latest release
- Keep branch-name references synced with the source repo
- Check packagist.org manually when a badge first renders as an error
When it happens
Trigger: Calling the Packagist dependency version badge/endpoint with a version query string that does not match any release returned by the Packagist API (e.g. /packagist/dd/mvn/dev-master when 'dev-master' no longer exists, or a typo like 'v2.0.1' vs '2.0.1').
Common situations: Requesting a branch name that was deleted, referencing a tag removed from the repo, querying a version of a package that never existed, or the upstream Packagist response lacking any matching version.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- no released version found
- no releases found
- no tags found
- version not found
- version requirement not found
AI-assisted analysis of badges/shields@766fd8bc89 (2026-08-30).
Data as JSON: /api/errors/f5772844fa27089d.
Report an issue: GitHub.