badges/shields · error · InvalidResponse

invalid response data

Error message

invalid response data

What it means

The Debian package badge service throws InvalidResponse with prettyMessage 'invalid response data' in Debian.handle when the response from the Debian package tracker has no entry for the requested package at data[0][packageName]. The response shape was valid overall but the expected package key is missing.

Source

Thrown at services/debian/debian.service.js:80

      schema,
      url: 'https://api.ftp-master.debian.org/madison',
      options: {
        searchParams: {
          f: 'json',
          s: distribution,
          package: packageName,
        },
      },
    })
    if (!data.length) {
      throw new NotFound()
    }
    // Distribution can change compared to request, for example requesting
    // "stretch" may map to "stable" in results, so can't use value from
    // request as is. Just take the first one instead.
    const packageData = data[0][packageName]
    if (!packageData) {
      throw new InvalidResponse({ prettyMessage: 'invalid response data' })
    }
    const distKeys = Object.keys(packageData)
    if (!distKeys) {
      throw new NotFound()
    }
    const versions = Object.keys(packageData[distKeys[0]])
    return renderVersionBadge({ version: latest(versions) })
  }
}

View on GitHub (pinned to 766fd8bc89)

Solutions

  1. Verify the package exists in the requested distribution (e.g. https://packages.debian.org/<suite>/<package>)
  2. Check the package name spelling and case exactly as Debian packages it
  3. Try a different suite/codename where the package is available
  4. If the API schema changed, the service itself may need updating

Example fix

// before
/badge/debian/version/nonexistent-pkg/stable -> invalid response data
// after
/badge/debian/version/bash/stable
Defensive patterns

Strategy: validation

Validate before calling

async function debianPackageExists(suite, pkg) {
  const url = `https://sources.debian.org/api/src/${encodeURIComponent(pkg)}/`
  const res = await fetch(url)
  if (!res.ok) return false
  const data = await res.json()
  return Array.isArray(data) && data.length > 0
}

Type guard

function hasPackageData(data, packageName) {
  return Array.isArray(data) && data.length > 0 && data[0]?.[packageName] != null
}

Try / catch

try {
  const badge = await getDebianVersionBadge(pkg, suite)
} catch (err) {
  if (err.prettyMessage === 'invalid response data') {
    badge = 'package not found'
  } else throw err
}

Prevention

When it happens

Trigger: The requested package name does not exist in the distribution's index, the JSON returned for the distribution has an empty/different structure, or the package name is misspelled or case-mismatched.

Common situations: Typo in the Debian package name; requesting a package from a suite (e.g. stretch, buster) where it isn't packaged; Debian API response schema changes.

Related errors


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