{"record":{"id":"242ea89d6833521f","repo":"RocketChat/Rocket.Chat","slug":"invalid-type-242ea8","errorCode":null,"errorMessage":"Invalid type","messagePattern":"Invalid type","errorType":"exception","errorClass":"Error","httpStatus":400,"severity":"error","filePath":"apps/meteor/server/api/v1/omnichannel/users.ts","lineNumber":71,"sourceCode":"\t\t\t\t);\n\t\t\t}\n\t\t\tif (this.urlParams.type === 'manager') {\n\t\t\t\tif (!(await hasAtLeastOnePermissionAsync(this.user, ['view-livechat-manager']))) {\n\t\t\t\t\treturn API.v1.forbidden();\n\t\t\t\t}\n\n\t\t\t\treturn API.v1.success(\n\t\t\t\t\tawait findManagers({\n\t\t\t\t\t\ttext,\n\t\t\t\t\t\tpagination: {\n\t\t\t\t\t\t\toffset,\n\t\t\t\t\t\t\tcount,\n\t\t\t\t\t\t\tsort,\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new Error('Invalid type');\n\t\t},\n\t\tasync post() {\n\t\t\tif (this.urlParams.type === 'agent') {\n\t\t\t\tconst user = await addAgent(this.bodyParams.username);\n\t\t\t\tif (user) {\n\t\t\t\t\treturn API.v1.success({ user });\n\t\t\t\t}\n\t\t\t} else if (this.urlParams.type === 'manager') {\n\t\t\t\tconst user = await addManager(this.bodyParams.username);\n\t\t\t\tif (user) {\n\t\t\t\t\treturn API.v1.success({ user });\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthrow new Error('Invalid type');\n\t\t\t}\n\n\t\t\treturn API.v1.failure();\n\t\t},","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/api/v1/omnichannel/users.ts#L53-L89","documentation":"Thrown by GET /api/v1/livechat/users/:type when the :type URL segment is neither 'agent' nor 'manager'. Note the values are SINGULAR in current versions — older Rocket.Chat releases (< 4.x) used the plural 'agents'/'managers' on this same route, so upgraded integrations that still send the plural form get this error. Each branch also has its own permission requirement (agent list: transfer-livechat-guest or edit-omnichannel-contact; manager list: view-livechat-manager) but wrong permission yields 403, not this error.","triggerScenarios":"GET /api/v1/livechat/users/agents or /livechat/users/managers (plural) on a current server; typos like 'agnt'; empty type segment due to URL building bug.","commonSituations":"Scripts or SDK clients written against Rocket.Chat 3.x kept in service after upgrade; mixed documentation usage — some docs pages still show the plural form.","solutions":["Use the singular form: GET /api/v1/livechat/users/agent or GET /api/v1/livechat/users/manager","After upgrading an old integration, audit every livechat/users/* call for plural path segments","Whitelist the two accepted values in your client so bad input fails fast locally"],"exampleFix":"// before\nrequest.get(api('livechat/users/agents')).set(credentials);\n// after\nrequest.get(api('livechat/users/agent')).set(credentials);","handlingStrategy":"validation","validationCode":"const type = String(rawType).toLowerCase().replace(/s$/, ''); // 'agents' -> 'agent'\nif (!['agent', 'manager'].includes(type)) throw new TypeError(`invalid type ${rawType}`);\nawait fetch(`${server}/api/v1/livechat/users/${type}`, { headers });","typeGuard":"type LivechatUserType = 'agent' | 'manager';\nconst isLivechatUserType = (t: string): t is LivechatUserType => t === 'agent' || t === 'manager';","tryCatchPattern":"const body = await (await fetch(url, { headers })).json();\nif (!body.success && body.error === 'Invalid type') { /* re-map plural->singular and retry once */ }","preventionTips":["Type the path segment as the literal union 'agent' | 'manager' in your client","After a Rocket.Chat upgrade, grep your codebase for livechat/users/agents|managers"],"tags":["rest-api","livechat","url-params","validation","version-migration"],"backgroundTag":"invalid-url-parameter","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}