{"record":{"id":"2a2de1eb5bc88392","repo":"badges/shields","slug":"user-not-found","errorCode":null,"errorMessage":"user not found","messagePattern":"user not found","errorType":"exception","errorClass":"NotFound","httpStatus":404,"severity":"info","filePath":"services/hackernews/hackernews-user-karma.service.js","lineNumber":60,"sourceCode":"      color,\n      style: 'social',\n    }\n  }\n\n  async fetch({ id }) {\n    return this._requestJson({\n      schema,\n      url: `https://hacker-news.firebaseio.com/v0/user/${id}.json`,\n      httpErrors: {\n        404: 'user not found',\n      },\n    })\n  }\n\n  async handle({ id }) {\n    const json = await this.fetch({ id })\n    if (json == null) {\n      throw new NotFound({ prettyMessage: 'user not found' })\n    }\n    const { karma } = json\n    return this.constructor.render({\n      karma,\n      id,\n    })\n  }\n}\n","sourceCodeStart":42,"sourceCodeEnd":69,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/hackernews/hackernews-user-karma.service.js#L42-L69","documentation":"The HackerNews karma service throws this NotFound when the HackerNews API (Firebase endpoint) returns null for the user id — the API's way of signaling a user that does not exist. The service converts null into a 'user not found' badge error.","triggerScenarios":"Requesting the karma badge for a HackerNews username that does not exist, was deleted, or was renamed; passing a dead/banned account id to the badge.","commonSituations":"README badges left pointing at a user who deleted their HN account; typos in the id query parameter; usernames that were removed by moderation.","solutions":["Verify the username exists on news.ycombinator.com/user?id=<name>","Correct the id parameter in the badge URL (case and spelling matter)","Remove the karma badge if the account was deleted"],"exampleFix":"// before\n[![karma](https://img.shields.io/hackernews/karma/dangg)]\n// after (correct username)\n[![karma](https://img.shields.io/hackernews/karma/dang)]","handlingStrategy":"type-guard","validationCode":"const json = await (await fetch(`https://hacker-news.firebaseio.com/v0/user/${id}.json`)).json()\nif (json == null) console.warn(`HackerNews user ${id} does not exist`)","typeGuard":"const userExists = (json) => json != null && typeof json === 'object' && typeof json.karma === 'number'","tryCatchPattern":"try {\n  const karma = await service.handle({ id })\n} catch (e) {\n  if (e.prettyMessage === 'user not found') {\n    // render 'unknown user' badge\n  } else throw e\n}","preventionTips":["Check news.ycombinator.com/user?id=<name> resolves before adding the badge","Remember deleted HN accounts return null from the API","Keep the id query parameter exact (usernames are case-sensitive as stored)"],"tags":["hackernews","user","not-found"],"backgroundTag":"user-not-found","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}