badges/shields · error · NotFound

subreddit not found

Error message

subreddit not found

What it means

The Reddit subreddit-subscribers badge throws NotFound 'subreddit not found' when the Reddit API response lacks json.data.subscribers. Reddit returns a 200 with a listing/error payload for nonexistent, banned, or private subreddits, so the service checks for the subscribers field and signals the subreddit doesn't exist.

Source

Thrown at services/reddit/subreddit-subscribers.service.js:63

  async fetch({ subreddit }) {
    return this._requestJson({
      schema,
      // API requests with a bearer token should be made to https://oauth.reddit.com, NOT www.reddit.com.
      url: this.authHelper.isConfigured
        ? `https://oauth.reddit.com/r/${subreddit}/about.json`
        : `https://www.reddit.com/r/${subreddit}/about.json`,
      httpErrors: {
        404: 'subreddit not found',
        403: 'subreddit is private',
      },
    })
  }

  transform(json) {
    const subscribers = json.data.subscribers
    if (subscribers === undefined) {
      throw new NotFound({ prettyMessage: 'subreddit not found' })
    }
    return { subscribers }
  }

  async handle({ subreddit }) {
    const json = await this.fetch({ subreddit })
    const { subscribers } = this.transform(json)
    return this.constructor.render({
      subreddit,
      subscribers,
    })
  }
}

View on GitHub (pinned to 766fd8bc89)

Solutions

  1. Verify the subreddit name exists by visiting reddit.com/r/<name>
  2. Check the subreddit isn't private, banned, or quarantined
  3. If requests come from a blocked IP, configure a proxy or check Reddit API rate limiting

Example fix

// before
/badge/reddit-subscribers/mysubreddit  (typo)
// after
/badge/reddit-subscribers/javascript
Defensive patterns

Strategy: try-catch

Validate before calling

const r = await fetch(`https://www.reddit.com/r/${subreddit}/about.json`)
const j = await r.json()
if (j?.data?.subscribers === undefined) throw new Error(`subreddit ${subreddit} not found or inaccessible`)

Type guard

function isSubredditData(json) {
  return typeof json?.data?.subscribers === 'number'
}

Try / catch

try {
  const badge = await service.handle({ subreddit })
} catch (err) {
  if (err instanceof NotFound && err.prettyMessage === 'subreddit not found') {
    return renderBadge({ label: 'reddit', message: 'n/a' })
  }
  throw err
}

Prevention

When it happens

Trigger: Requesting a badge for a subreddit that doesn't exist, was banned/quarantined, is private, or whose API response shape lacks data.subscribers (e.g. rate-limited or blocked responses).

Common situations: Typos in the subreddit name; subreddit banned or set private since the badge was added; Reddit blocking datacenter IPs so responses lack subscriber data; case-sensitive naming mistakes.

Related errors


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