{"record":{"id":"a5b0e3679b896872","repo":"badges/shields","slug":"invalid-user-id-format","errorCode":null,"errorMessage":"invalid user id format","messagePattern":"invalid user id format","errorType":"exception","errorClass":"NotFound","httpStatus":404,"severity":"error","filePath":"services/mastodon/mastodon-follow.service.js","lineNumber":72,"sourceCode":"      message: metric(followers),\n      style: 'social',\n      link: [\n        `https://${domain}/users/${username}`,\n        `https://${domain}/users/${username}/followers`,\n      ],\n    }\n  }\n\n  async fetch({ id, domain }) {\n    return this._requestJson({\n      schema,\n      url: `https://${domain}/api/v1/accounts/${id}/`,\n    })\n  }\n\n  async handle({ id }, { domain = 'mastodon.social' }) {\n    if (isNaN(id))\n      throw new NotFound({ prettyMessage: 'invalid user id format' })\n    domain = domain.replace(/^https?:\\/\\//, '')\n    const data = await this.fetch({ id, domain })\n    return this.constructor.render({\n      username: data.username,\n      followers: data.followers_count,\n      domain,\n    })\n  }\n}\n","sourceCodeStart":54,"sourceCodeEnd":82,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/mastodon/mastodon-follow.service.js#L54-L82","documentation":"The Mastodon follower badge identifies a user by numeric account id. handle() validates that the id is numeric with isNaN(id); a non-numeric id cannot be a valid Mastodon account id, so it throws NotFound('invalid user id format') before any request is made.","triggerScenarios":"Passing a username string (e.g. '@user' or 'user@example.social') instead of the numeric account id, or an empty/alphanumeric id, making isNaN(id) true.","commonSituations":"Users copying the handle from the profile URL instead of the numeric id (visible in the .json or via the account lookup API), or mistakenly believing Mastodon badges accept @user@domain handles.","solutions":["Use Mastodon's numeric account id (e.g. from https://mastodon.social/api/v1/accounts/lookup?account_name=user).","Replace the username in the badge URL with that numeric id.","Keep the domain parameter as the instance hostname without protocol."],"exampleFix":"// before\n/mastodon/follow/@Gargron.svg\n// after\n/mastodon/follow/2393.svg","handlingStrategy":"validation","validationCode":"const mastodonId = '2393'\nif (!/^\\d+$/.test(mastodonId)) throw new Error('Mastodon badge requires a numeric account id, not a @username')","typeGuard":"const isMastodonId = (id) => typeof id === 'string' && /^\\d+$/.test(id)","tryCatchPattern":"try {\n  return await mastodonService.handle({ id }, { domain })\n} catch (e) {\n  if (e instanceof NotFound && e.prettyMessage === 'invalid user id format') {\n    // resolve handle -> numeric id via /api/v1/accounts/lookup and retry\n  }\n  throw e\n}","preventionTips":["Resolve usernames to numeric ids via the accounts/lookup endpoint before building badges.","Never pass @user@domain handles as the id path segment.","Sanitize/validate the id parameter in any tooling that generates badge URLs."],"tags":["mastodon","validation","not-found"],"backgroundTag":"invalid-input-format","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}