badges/shields · warning · InvalidResponse

invalid response data

Error message

invalid response data

What it means

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.

Source

Thrown at services/hackage/hackage-version.service.js:44

  async fetch({ packageName }) {
    return this._request({
      url: `https://hackage.haskell.org/package/${packageName}/${packageName}.cabal`,
    })
  }

  static transform(data) {
    const lines = data.split('\n')
    const versionLines = lines.filter(e => /^version:/i.test(e) === true)
    return versionLines[0].split(/:/)[1].trim()
  }

  async handle({ packageName }) {
    const { buffer } = await this.fetch({ packageName })
    try {
      const version = this.constructor.transform(buffer)
      return renderVersionBadge({ version })
    } catch (e) {
      throw new InvalidResponse({ prettyMessage: 'invalid response data' })
    }
  }
}

View on GitHub (pinned to 766fd8bc89)

Solutions

  1. Verify the package name in the badge URL matches an existing Hackage package (hackage.haskell.org/package/<name>)
  2. Check the raw Hackage API response for the package to confirm it returns valid JSON with a version field
  3. Retry later if Hackage is having an outage or schema change
  4. If the package truly does not exist, remove or correct the badge

Example fix

// before
[![hackage](https://img.shields.io/hackage/v/haskel-pkg)]
// after (corrected package name)
[![hackage](https://img.shields.io/hackage/v/haskell-pkg)]
Defensive patterns

Strategy: try-catch

Validate before calling

const res = await fetch(`https://hackage.haskell.org/package/${packageName}`)
if (!res.ok) console.warn(`Hackage package ${packageName} not found or unreachable`)
const json = await res.json().catch(() => null)
if (!json) console.warn('Hackage did not return JSON')

Type guard

const isParseableVersion = (buffer) => { try { const j = JSON.parse(buffer); return typeof j?.version === 'string' } catch { return false } }

Try / catch

try {
  const version = HackageVersion.transform(buffer)
} catch (e) {
  // transform failures become InvalidResponse('invalid response data')
  // log the original error and show a fallback badge
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of badges/shields@766fd8bc89 (2026-08-30). Data as JSON: /api/errors/f7bb07cce54ac8d0. Report an issue: GitHub.