{"record":{"id":"ffc8c39eccf6f13d","repo":"badges/shields","slug":"invalid-community","errorCode":null,"errorMessage":"invalid community","messagePattern":"invalid community","errorType":"exception","errorClass":"InvalidParameter","httpStatus":null,"severity":"error","filePath":"services/lemmy/lemmy.service.js","lineNumber":48,"sourceCode":"    },\n  }\n\n  static defaultBadgeData = { label: 'community', namedLogo: 'lemmy' }\n\n  static render({ community, members }) {\n    return {\n      label: `subscribe to ${community}`,\n      message: metric(members),\n      style: 'social',\n      color: 'brightgreen',\n    }\n  }\n\n  async fetch({ community }) {\n    const splitAlias = community.split('@')\n    // The community will be in the format of `community@server`\n    if (splitAlias.length !== 2) {\n      throw new InvalidParameter({\n        prettyMessage: 'invalid community',\n      })\n    }\n\n    const host = splitAlias[1]\n\n    const data = await this._requestJson({\n      url: `https://${host}/api/v3/community`,\n      schema: lemmyCommunitySchema,\n      options: {\n        searchParams: {\n          name: community,\n        },\n      },\n      httpErrors: {\n        404: 'community not found',\n      },\n    })","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/lemmy/lemmy.service.js#L30-L66","documentation":"The Lemmy service throws InvalidParameter when the community string does not contain exactly one '@' after splitting, i.e. it is not in the required `community@server` format. This is a client-side input validation error thrown before any network request is made, so the badge URL itself is malformed.","triggerScenarios":"Calling /lemmy/<community> where community.split('@').length !== 2 — e.g. just 'lemmy' (no server), 'a@b@c' (multiple @), or an empty community segment.","commonSituations":"Forgetting the @server suffix in the badge URL; including 'https://' or a full URL; communities with special characters in their local name; using a URL-encoded slash that introduces extra '@' parts.","solutions":["Format the badge URL as /lemmy/<community>@<instance>, e.g. /lemmy/lemmy@lemmy.ml.","Remove any protocol prefix or trailing path from the community value.","URL-encode the community name if it contains characters outside [a-zA-Z0-9_.@-]."],"exampleFix":"// before\n/lemmy/lemmy\n// after\n/lemmy/lemmy@lemmy.ml","handlingStrategy":"validation","validationCode":"function validateLemmyCommunity(community) {\n  const parts = community.split('@');\n  if (parts.length !== 2 || !parts[0] || !parts[1]) {\n    throw new Error(`community must be in 'community@server' format, got: ${community}`);\n  }\n}","typeGuard":"function isCommunityAlias(value) {\n  return typeof value === 'string' && value.split('@').length === 2 && value.split('@').every(Boolean);\n}","tryCatchPattern":"try {\n  members = await getLemmyCommunityBadge(community);\n} catch (e) {\n  if (e.name === 'InvalidParameter') {\n    renderFallback(`'${community}' is not community@server format`);\n  } else throw e;\n}","preventionTips":["Always include the @server suffix: /lemmy/lemmy@lemmy.ml","Strip any https:// or path components from the community value","Validate the community format in CI before generating badge URLs"],"tags":["lemmy","invalid-parameter","input-validation","format"],"backgroundTag":"invalid-parameter-format","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}