badges/shields · error · Error

Unknown badge style: '${style}'

Error message

Unknown badge style: '${style}'

What it means

This is a plain Error (not ValidationError) thrown from makeBadge in badge-maker/lib/make-badge.js:46 when the requested style has no registered renderer in badgeRenderers. It fires only if a style value bypassed or post-dates validation — e.g. direct use of internal make-badge.js, or a validation/render table mismatch. Public API users who pass a valid style should never see it.

Source

Thrown at badge-maker/lib/make-badge.js:46

  if (format === 'json') {
    return JSON.stringify({
      label,
      message,
      logoWidth,
      // Only call normalizeColor for the JSON case: this is handled
      // internally by toSvgColor in the SVG case.
      color: normalizeColor(color),
      labelColor: normalizeColor(labelColor),
      link: links,
      name: label,
      value: message,
      idSuffix,
    })
  }

  const render = badgeRenderers[style]
  if (!render) {
    throw new Error(`Unknown badge style: '${style}'`)
  }

  logoWidth = +logoWidth || (logo ? DEFAULT_LOGO_HEIGHT : 0)

  return stripXmlWhitespace(
    render({
      label,
      message,
      links,
      logo,
      logoWidth,
      logoSize,
      logoPadding: logo && label.length ? 3 : 0,
      color: toSvgColor(color),
      labelColor: toSvgColor(labelColor),
      idSuffix,
    }),
  )

View on GitHub (pinned to 766fd8bc89)

Solutions

  1. Use the public makeBadge() API from badge-maker/lib/index.js, which validates style first
  2. Change style to one of the supported renderers: plastic, flat, flat-square, for-the-badge, social
  3. If you need a custom style, register a renderer in badgeRenderers or render the SVG yourself

Example fix

// before
import makeBadge from 'badge-maker/lib/make-badge.js'
makeBadge({ message: 'x', style: 'custom' })
// after
import { makeBadge } from 'badge-maker'
makeBadge({ message: 'x', style: 'flat' })
Defensive patterns

Strategy: try-catch

Try / catch

import { makeBadge, ValidationError } from 'badge-maker'
try {
  return makeBadge(badge)
} catch (e) {
  if (!(e instanceof ValidationError) && /Unknown badge style/.test(e.message)) {
    return makeBadge({ ...badge, style: 'flat' })
  }
  throw e
}

Prevention

When it happens

Trigger: Importing lib/make-badge.js directly and calling it with style: 'unknown-style'; or a patched/forked validator whose styleValues list is out of sync with badgeRenderers. Public makeBadge() users hit it only if validation was bypassed.

Common situations: Reaching into internal modules to skip validation, monkey-patching the renderer table, vendoring a modified copy where style lists diverged, or building a custom style without registering a renderer.


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