{"record":{"id":"6ddf929a4c6411a3","repo":"badges/shields","slug":"version-not-found","errorCode":null,"errorMessage":"version not found","messagePattern":"version not found","errorType":"exception","errorClass":"InvalidResponse","httpStatus":null,"severity":"error","filePath":"services/crates/crates-base.js","lineNumber":64,"sourceCode":"    return this._requestJson({\n      schema,\n      url,\n      httpErrors: version ? { 400: 'invalid version' } : {},\n    })\n  }\n\n  static getLatestVersion(response) {\n    return response.crate.max_stable_version\n      ? response.crate.max_stable_version\n      : response.crate.max_version\n  }\n\n  static getVersionObj(response) {\n    if (response.crate) {\n      const version = this.getLatestVersion(response)\n      const versionObj = response.versions.find(v => v.num === version)\n      if (versionObj === undefined) {\n        throw new InvalidResponse({ prettyMessage: 'version not found' })\n      }\n      return versionObj\n    }\n    return response.version\n  }\n}\n\nclass BaseCratesUserService extends BaseJsonService {\n  static defaultBadgeData = { label: 'crates.io' }\n\n  /**\n   * Fetches data from the crates.io API.\n   *\n   * @param {object} options - The options for the request\n   * @param {string} options.userId - The user ID.\n   * @returns {Promise<object>} the JSON response from the API.\n   */\n  async fetch({ userId }) {","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/crates/crates-base.js#L46-L82","documentation":"crates-base's getVersionObj looks up the full version object matching the chosen latest version number among response.versions; if none matches it throws InvalidResponse with 'version not found'. It is an internal consistency check: the crates.io response listed a latest version but did not include its detail object.","triggerScenarios":"getVersionObj receives a crates.io API response where response.crate exists, getLatestVersion picks a version (e.g. max_version or max_stable_version), but response.versions contains no entry with v.num === version.","commonSituations":"crates.io API changes or partial responses omitting version details, yanked versions filtered out, or transient upstream inconsistencies during republishing.","solutions":["Retry the badge request — crates.io may have returned a momentarily inconsistent response","Check the crate on crates.io and confirm the latest version is listed with its details","Verify the crate name spelling in the badge URL","Report to the badge maintainers if crates.io consistently omits the version object"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"function responseIsConsistent(res) {\n  if (!res.crate) return true;\n  const latest = res.crate.max_stable_version || res.crate.max_version || res.crate.newest_version;\n  return latest == null || res.versions.some(v => v.num === latest);\n}","typeGuard":"function hasMatchingVersionObj(res) {\n  const v = res.crate && (res.crate.max_stable_version || res.crate.max_version);\n  return !v || res.versions?.some(e => e.num === v);\n}","tryCatchPattern":"try {\n  const badge = await fetchBadge(`/crates/l/${crate}`);\n} catch (e) {\n  if (e.message.includes('version not found')) await retryWithBackoff(3);\n  else throw e;\n}","preventionTips":["Retry transiently — crates.io can return momentarily inconsistent payloads","Check the crate page on crates.io for yanked or republished latest versions","Verify the crate name spelling","Report persistent mismatches to crates.io / badge maintainers"],"tags":["crates-io","invalid-response","inconsistent-data"],"backgroundTag":"upstream-response-mismatch","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}