{"record":{"id":"f5772844fa27089d","repo":"badges/shields","slug":"invalid-version","errorCode":null,"errorMessage":"invalid version","messagePattern":"invalid version","errorType":"exception","errorClass":"NotFound","httpStatus":404,"severity":"error","filePath":"services/packagist/packagist-dependency-version.service.js","lineNumber":102,"sourceCode":"\n    if (version === '') {\n      packageVersion = this.findLatestRelease(versions)\n    } else {\n      try {\n        packageVersion = await this.findSpecifiedVersion(\n          versions,\n          user,\n          repo,\n          version,\n          server,\n        )\n      } catch (e) {\n        packageVersion = null\n      }\n    }\n\n    if (!packageVersion) {\n      throw new NotFound({ prettyMessage: 'invalid version' })\n    }\n\n    if (!packageVersion.require) {\n      throw new NotFound({ prettyMessage: 'version requirement not found' })\n    }\n\n    // All dependencies' names in the 'require' section from the response should be lowercase,\n    // so that we can compare lowercase name of the dependency given via url by the user.\n    Object.keys(packageVersion.require).forEach(dependency => {\n      packageVersion.require[dependency.toLowerCase()] =\n        packageVersion.require[dependency]\n    })\n\n    const depLowerCase = dependency.toLowerCase()\n\n    if (!packageVersion.require[depLowerCase]) {\n      throw new NotFound({ prettyMessage: 'version requirement not found' })\n    }","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/packagist/packagist-dependency-version.service.js#L84-L120","documentation":"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'.","triggerScenarios":"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').","commonSituations":"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.","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"],"exampleFix":"// before\n/packagist/symfony/console/versio?version=dev-master-2.x\n// after\n/packagist/symfony/console/versio?version=v6.4.0","handlingStrategy":"validation","validationCode":"const knownVersions = await getPackagistVersions(user, repo)\nif (!knownVersions.includes(requestedVersion)) throw new Error(`Unknown version ${requestedVersion}; valid: ${knownVersions.join(', ')}`)","typeGuard":"function isValidPackagistVersion(v) {\n  return typeof v === 'string' && (v === 'latest' || /^v?\\d+(\\.\\d+)*(\\.\\d+)?([-.][\\w.]+)?$/.test(v))\n}","tryCatchPattern":"try {\n  const { dependencyVersion } = await dependencyVersion(user, repo, dep, version)\n} catch (e) {\n  if (e instanceof NotFound) console.warn(`Version '${version}' not found on Packagist; check packagist.org/${user}/${repo}`)\n  else throw e\n}","preventionTips":["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"],"tags":["packagist","not-found","bad-request","versioning"],"backgroundTag":"resource-not-found","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}