{"record":{"id":"24fb78ba965381a9","repo":"badges/shields","slug":"subreddit-not-found","errorCode":null,"errorMessage":"subreddit not found","messagePattern":"subreddit not found","errorType":"exception","errorClass":"NotFound","httpStatus":null,"severity":"error","filePath":"services/reddit/subreddit-subscribers.service.js","lineNumber":63,"sourceCode":"\n  async fetch({ subreddit }) {\n    return this._requestJson({\n      schema,\n      // API requests with a bearer token should be made to https://oauth.reddit.com, NOT www.reddit.com.\n      url: this.authHelper.isConfigured\n        ? `https://oauth.reddit.com/r/${subreddit}/about.json`\n        : `https://www.reddit.com/r/${subreddit}/about.json`,\n      httpErrors: {\n        404: 'subreddit not found',\n        403: 'subreddit is private',\n      },\n    })\n  }\n\n  transform(json) {\n    const subscribers = json.data.subscribers\n    if (subscribers === undefined) {\n      throw new NotFound({ prettyMessage: 'subreddit not found' })\n    }\n    return { subscribers }\n  }\n\n  async handle({ subreddit }) {\n    const json = await this.fetch({ subreddit })\n    const { subscribers } = this.transform(json)\n    return this.constructor.render({\n      subreddit,\n      subscribers,\n    })\n  }\n}\n","sourceCodeStart":45,"sourceCodeEnd":77,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/reddit/subreddit-subscribers.service.js#L45-L77","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Verify the subreddit name exists by visiting reddit.com/r/<name>","Check the subreddit isn't private, banned, or quarantined","If requests come from a blocked IP, configure a proxy or check Reddit API rate limiting"],"exampleFix":"// before\n/badge/reddit-subscribers/mysubreddit  (typo)\n// after\n/badge/reddit-subscribers/javascript","handlingStrategy":"try-catch","validationCode":"const r = await fetch(`https://www.reddit.com/r/${subreddit}/about.json`)\nconst j = await r.json()\nif (j?.data?.subscribers === undefined) throw new Error(`subreddit ${subreddit} not found or inaccessible`)","typeGuard":"function isSubredditData(json) {\n  return typeof json?.data?.subscribers === 'number'\n}","tryCatchPattern":"try {\n  const badge = await service.handle({ subreddit })\n} catch (err) {\n  if (err instanceof NotFound && err.prettyMessage === 'subreddit not found') {\n    return renderBadge({ label: 'reddit', message: 'n/a' })\n  }\n  throw err\n}","preventionTips":["Visit reddit.com/r/<name> to confirm existence before adding the badge","Account for banned/private subreddits when removing projects","If self-hosting, ensure egress IPs are not blocked by Reddit (rate limits/proxies)"],"tags":["badge","reddit","not-found"],"backgroundTag":"resource-not-found-in-upstream","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}