{"record":{"id":"f7bb07cce54ac8d0","repo":"badges/shields","slug":"invalid-response-data-f7bb07","errorCode":null,"errorMessage":"invalid response data","messagePattern":"invalid response data","errorType":"exception","errorClass":"InvalidResponse","httpStatus":424,"severity":"warning","filePath":"services/hackage/hackage-version.service.js","lineNumber":44,"sourceCode":"  async fetch({ packageName }) {\n    return this._request({\n      url: `https://hackage.haskell.org/package/${packageName}/${packageName}.cabal`,\n    })\n  }\n\n  static transform(data) {\n    const lines = data.split('\\n')\n    const versionLines = lines.filter(e => /^version:/i.test(e) === true)\n    return versionLines[0].split(/:/)[1].trim()\n  }\n\n  async handle({ packageName }) {\n    const { buffer } = await this.fetch({ packageName })\n    try {\n      const version = this.constructor.transform(buffer)\n      return renderVersionBadge({ version })\n    } catch (e) {\n      throw new InvalidResponse({ prettyMessage: 'invalid response data' })\n    }\n  }\n}\n","sourceCodeStart":26,"sourceCodeEnd":48,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/hackage/hackage-version.service.js#L26-L48","documentation":"The Hackage version service throws this InvalidResponse when transform(buffer) throws for any reason while parsing the package metadata buffer fetched from Hackage. The catch-all converts any parse/format failure into a single 'invalid response data' error, hiding the underlying cause.","triggerScenarios":"The Hackage package name is wrong so the fetched buffer is not the expected JSON (404 HTML/redirect body), or the response shape changed so transform() cannot extract the version field.","commonSituations":"Typo in the Haskell package name in the badge URL; package renamed or deprecated on Hackage; upstream Hackage API/format drift; network middleware returning an error page instead of JSON.","solutions":["Verify the package name in the badge URL matches an existing Hackage package (hackage.haskell.org/package/<name>)","Check the raw Hackage API response for the package to confirm it returns valid JSON with a version field","Retry later if Hackage is having an outage or schema change","If the package truly does not exist, remove or correct the badge"],"exampleFix":"// before\n[![hackage](https://img.shields.io/hackage/v/haskel-pkg)]\n// after (corrected package name)\n[![hackage](https://img.shields.io/hackage/v/haskell-pkg)]","handlingStrategy":"try-catch","validationCode":"const res = await fetch(`https://hackage.haskell.org/package/${packageName}`)\nif (!res.ok) console.warn(`Hackage package ${packageName} not found or unreachable`)\nconst json = await res.json().catch(() => null)\nif (!json) console.warn('Hackage did not return JSON')","typeGuard":"const isParseableVersion = (buffer) => { try { const j = JSON.parse(buffer); return typeof j?.version === 'string' } catch { return false } }","tryCatchPattern":"try {\n  const version = HackageVersion.transform(buffer)\n} catch (e) {\n  // transform failures become InvalidResponse('invalid response data')\n  // log the original error and show a fallback badge\n}","preventionTips":["Verify the exact Hackage package name before building the badge URL","Check hackage.haskell.org availability if many packages fail at once","Validate that the API endpoint returns JSON with the expected version field"],"tags":["hackage","haskell","invalid-response","parse-error"],"backgroundTag":"invalid-response-data","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}