{"record":{"id":"e69d5090141d1168","repo":"badges/shields","slug":"private","errorCode":null,"errorMessage":"private","messagePattern":"private","errorType":"exception","errorClass":"InvalidResponse","httpStatus":null,"severity":"info","filePath":"services/freecodecamp/freecodecamp-points.service.js","lineNumber":70,"sourceCode":"    return this._requestJson({\n      schema,\n      url: 'https://api.freecodecamp.org/users/get-public-profile',\n      options: {\n        searchParams: {\n          username,\n        },\n      },\n      httpErrors: { 404: 'profile not found' },\n    })\n  }\n\n  static transform(response, username) {\n    const { entities } = response\n\n    const { points } = entities.user[username]\n\n    if (points === null) {\n      throw new InvalidResponse({ prettyMessage: 'private' })\n    }\n\n    return points\n  }\n\n  async handle({ username }) {\n    const response = await this.fetch({ username })\n    const points = this.constructor.transform(response, username)\n    return this.constructor.render({ points })\n  }\n}\n","sourceCodeStart":52,"sourceCodeEnd":82,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/freecodecamp/freecodecamp-points.service.js#L52-L82","documentation":"The freeCodeCamp points service reads response.entities.user[username].points from the API response. When the user's points are null — freeCodeCamp marks profiles private — the transform throws InvalidResponse with prettyMessage 'private', indicating the data exists but is intentionally hidden.","triggerScenarios":"Requesting a freeCodeCamp points badge for a username whose profile privacy settings hide their points (points === null in the API response).","commonSituations":"Badge on the profile of a user who has opted out of public stats; user later enabled privacy mode so a previously working badge starts failing; case-sensitivity issues resolved to a private account.","solutions":["Respect the user's privacy choice — remove the points badge or replace it with a non-stat badge","Ask the profile owner to make their points public in freeCodeCamp privacy settings","Verify the username is correct and points to the intended public account"],"exampleFix":"// before\n/badge/freecodecamp/points/privateuser  // points hidden\n// after (choose public user or drop badge)\n/badge/freecodecamp/points/publicuser","handlingStrategy":"try-catch","validationCode":"async function pointsArePublic(username) {\n  const res = await fetch(`https://api.freecodecamp.org/api/users/get-public-profile?username=${username}`)\n  const json = await res.json()\n  const entity = json.entities && json.entities.user && json.entities.user[username]\n  return Boolean(entity) && entity.points !== null\n}\n// only render the badge when points are public","typeGuard":"function hasPublicPoints(response, username) {\n  const user = response?.entities?.user?.[username]\n  return user != null && typeof user.points === 'number'\n}","tryCatchPattern":"try {\n  const points = await getFreeCodeCampPoints(username)\n} catch (e) {\n  if (e.prettyMessage === 'private') {\n    renderPlaceholderBadge('points private')\n  } else throw e\n}","preventionTips":["Check that the profile's points are publicly visible before adding a badge","Handle the case where a user later switches to private mode (badge degrades gracefully)","Confirm the username spelling matches the public profile","Offer a fallback badge type for users with private stats"],"tags":["freecodecamp","privacy","invalid-response","user-profile"],"backgroundTag":"user-profile-private","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}