badges/shields · error · InvalidResponse

Version missing in ${filename}

Error message

Version missing in ${filename}

What it means

The GitHub R-package service extracts the version from a package DESCRIPTION file using `versionRegExp`. If the regex finds no `Version:` field in the fetched content, `transform` throws `InvalidResponse` with 'Version missing in <filename>'. The file was downloaded fine, but it does not look like a valid R package DESCRIPTION.

Source

Thrown at services/github/github-r-package.service.js:73

        ],
      },
    },
  }

  static defaultBadgeData = { label: 'R' }

  static render({ version, branch }) {
    return renderVersionBadge({
      version,
      tag: branch,
      defaultLabel: 'R',
    })
  }

  static transform(content, filename) {
    const match = versionRegExp.exec(content)
    if (!match) {
      throw new InvalidResponse({
        prettyMessage: `Version missing in ${filename}`,
      })
    }

    return {
      version: match[1],
    }
  }

  async handle({ user, repo, branch }, { filename = 'DESCRIPTION' }) {
    const content = await fetchRepoContent(this, {
      user,
      repo,
      branch,
      filename,
    })
    const { version } = this.constructor.transform(content, filename)
    return this.constructor.render({ version, branch })

View on GitHub (pinned to 766fd8bc89)

Solutions

  1. Add a `Version: x.y.z` field to the DESCRIPTION file
  2. Verify the badge URL's filename/path points at the real DESCRIPTION on the intended branch
  3. Check the fetched content on GitHub to confirm it is the R package DESCRIPTION, not an error page

Example fix

// before (DESCRIPTION)
Package: mypkg
// after
Package: mypkg
Version: 1.2.3
Defensive patterns

Strategy: validation

Validate before calling

const content = await fetch(rawDescriptionUrl).then(r => r.text())
if (!/^Version:\s*.+$/m.test(content)) {
  throw new Error('DESCRIPTION lacks a Version field')
}

Type guard

null

Try / catch

try {
  await fetchRPackageBadge(user, repo, path)
} catch (e) {
  if (/^Version missing in /.test(e.message)) return 'version unknown'
  throw e
}

Prevention

When it happens

Trigger: Fetching the DESCRIPTION from a repo/path where the file lacks a `Version:` line; the URL points at a different file (e.g. wrong filename or an HTML error page saved as the file); the branch's DESCRIPTION is malformed.

Common situations: Path/filename typo in the badge URL so a non-DESCRIPTION file is fetched; R package source without a Version field (unusual but possible in hand-written DESCRIPTION); branch where DESCRIPTION was edited and the Version line deleted; serving a 404 HTML page at the expected path.

Related errors


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