{"record":{"id":"535065ef625dde51","repo":"RocketChat/Rocket.Chat","slug":"param-params-name-key-is-required","errorCode":null,"errorMessage":"Param \"${params.name?.key}\" is required","messagePattern":"Param \"(.+?)\" is required","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/api/v1/channels.ts","lineNumber":1019,"sourceCode":"\tuser: { value: string };\n\tname?: { key: string; value?: string };\n\tmembers?: { key: string; value?: string[] };\n\tcustomFields?: { key: string; value?: string };\n\tteams?: { key: string; value?: string[] };\n\tteamId?: { key: string; value?: string };\n}) {\n\tconst teamId = params.teamId?.value;\n\n\tconst team = teamId && (await Team.getInfoById(teamId));\n\tif (\n\t\t(!teamId && !(await hasPermissionAsync(params.user.value, 'create-c'))) ||\n\t\t(teamId && team && !(await hasPermissionAsync(params.user.value, 'create-team-channel', team.roomId)))\n\t) {\n\t\tthrow new Error('unauthorized');\n\t}\n\n\tif (!params.name?.value) {\n\t\tthrow new Error(`Param \"${params.name?.key}\" is required`);\n\t}\n\n\tif (params.members?.value && !Array.isArray(params.members.value)) {\n\t\tthrow new Error(`Param \"${params.members.key}\" must be an array if provided`);\n\t}\n\n\tif (params.customFields?.value && !(typeof params.customFields.value === 'object')) {\n\t\tthrow new Error(`Param \"${params.customFields.key}\" must be an object if provided`);\n\t}\n\n\tif (params.teams?.value && !Array.isArray(params.teams.value)) {\n\t\tthrow new Error(`Param ${params.teams.key} must be an array`);\n\t}\n}\n\nasync function createChannel(\n\tuserId: string,\n\tparams: {","sourceCodeStart":1001,"sourceCodeEnd":1037,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/e4b8178b205510181a96ceefee043d0abcd13e5a/apps/meteor/server/api/v1/channels.ts#L1001-L1037","documentation":"Validation error from POST channels.create: the name parameter is missing, empty, or undefined. validateChannelParams checks params.name?.value before creating anything, so an absent or blank channel name fails fast with a 400-class error.","triggerScenarios":"POST /api/v1/channels.create where the JSON body omits 'name', sends name: '' or name: null, or a bug in the caller sends the name under a different key (e.g. 'channelName').","commonSituations":"Form submitted before the user typed a name; whitespace-only or empty-string name from a template; key mismatch after refactoring client code; scripts building bodies dynamically where name resolves to undefined.","solutions":["Ensure the request body includes a non-empty 'name' field (required) at the top level of the JSON","Trim and validate the name client-side before sending; disable submit until filled","Check for typos in the payload key — it must be exactly 'name'"],"exampleFix":"// before\nPOST /api/v1/channels.create { \"channelName\": \"dev-talk\" }\n\n// after\nPOST /api/v1/channels.create { \"name\": \"dev-talk\" }","handlingStrategy":"validation","validationCode":"const name = (body.name ?? '').toString().trim();\nif (!name) throw new Error('channels.create: name is required');","typeGuard":"const hasChannelName = (b: { name?: unknown }): b is { name: string } =>\n  typeof b.name === 'string' && b.name.trim().length > 0;","tryCatchPattern":"try { await POST('/api/v1/channels.create', body); } catch (e) {\n  if (/is required/.test(e.message)) { /* highlight the name field */ }\n}","preventionTips":["Validate required fields client-side before submit","Disable submit buttons until the name field has non-whitespace content"],"tags":["rest-api","channels","validation","rocket-chat"],"backgroundTag":"missing-required-argument","analyzedSha":"e4b8178b205510181a96ceefee043d0abcd13e5a","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}