{"record":{"id":"800528c84d46642d","repo":"badges/shields","slug":"invalid-alias","errorCode":null,"errorMessage":"invalid alias","messagePattern":"invalid alias","errorType":"exception","errorClass":"InvalidParameter","httpStatus":null,"severity":"error","filePath":"services/matrix/matrix.service.js","lineNumber":233,"sourceCode":"        ).length\n      : 0\n  }\n\n  async fetch({ roomAlias, serverFQDN, fetchMode }) {\n    let host\n    if (serverFQDN === undefined) {\n      const splitAlias = roomAlias.split(':')\n      // A room alias can either be in the form #localpart:server or\n      // #localpart:server:port.\n      switch (splitAlias.length) {\n        case 2:\n          host = splitAlias[1]\n          break\n        case 3:\n          host = `${splitAlias[1]}:${splitAlias[2]}`\n          break\n        default:\n          throw new InvalidParameter({ prettyMessage: 'invalid alias' })\n      }\n    } else {\n      host = serverFQDN\n    }\n    if (host.toLowerCase() === 'matrix.org' || fetchMode === 'summary') {\n      // summary endpoint (default for matrix.org)\n      return await this.fetchSummary({ host, roomAlias })\n    } else {\n      // guest access\n      return await this.fetchGuest({ host, roomAlias })\n    }\n  }\n\n  async handle({ roomAlias }, { server_fqdn: serverFQDN, fetchMode }) {\n    const members = await this.fetch({ roomAlias, serverFQDN, fetchMode })\n    return this.constructor.render({ members })\n  }\n}","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/matrix/matrix.service.js#L215-L251","documentation":"This error is thrown by the Matrix service's fetch() when an alias string cannot be parsed into a valid host. Aliases are split on ':' and must yield 1-3 parts; any other segment count falls into the default branch and throws InvalidParameter with 'invalid alias'. It indicates the caller supplied a malformed alias identifier (e.g. a room or user alias) that does not conform to the expected #alias:host or #alias:host:port style shapes.","triggerScenarios":"Calling fetch (directly or via members) with an alias containing the delimiter ':' but producing 0, 4 or more split segments, e.g. '#room:a:b:c' or an empty string containing stray colons.","commonSituations":"Passing a full matrix.to URL instead of an alias, including an encoded or copy-pasted alias with extra colons (port or escape sequences), or handing the service an empty/whitespace alias with delimiters.","solutions":["Print and inspect the alias value; count the colon-separated segments — it must split into 1, 2, or 3 parts.","Strip URL prefixes/encoding: use the raw alias like '#room:example.org', not 'https://matrix.to/#/%23room%3Aexample.org'.","Remove any trailing/extra colons or port suffixes from the alias before calling.","If no alias is needed, pass the server FQDN instead so the else branch (host = serverFQDN) is used."],"exampleFix":"// before\nconst res = await matrixService.fetch({ alias: 'https://matrix.to/#/%23room%3Aexample.org' })\n// after\nconst alias = decodeURIComponent('https://matrix.to/#/%23room%3Aexample.org'.split('/#/')[1]).replace(/:$/, '')\nconst res = await matrixService.fetch({ alias })","handlingStrategy":"validation","validationCode":"function isValidAlias(alias) {\n  if (typeof alias !== 'string') return false\n  const parts = alias.split(':')\n  return parts.length >= 1 && parts.length <= 3 && parts.every(p => p.length > 0)\n}\nif (!isValidAlias(alias)) throw new Error(`invalid alias: ${alias}`)","typeGuard":"function isAlias(v) {\n  return typeof v === 'string' && /^[^:]+(:[^:]+){0,2}$/.test(v)\n}","tryCatchPattern":"try {\n  const data = await matrixService.fetch({ alias })\n} catch (err) {\n  if (err && err.prettyMessage === 'invalid alias') {\n    throw new Error(`Alias '${alias}' is malformed; use #name:host form`)\n  }\n  throw err\n}","preventionTips":["Validate alias shape (1-3 colon-separated non-empty segments) before calling fetch.","Pass decoded raw aliases, never full matrix.to URLs or percent-encoded strings.","Trim whitespace and strip stray trailing colons from user-supplied input.","Prefer server FQDN input when an alias is not actually needed."],"tags":["invalid-parameter","input-validation","matrix","alias-parsing"],"backgroundTag":"invalid-input-format","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}