{"record":{"id":"ded744e5ba0e4578","repo":"RocketChat/Rocket.Chat","slug":"invalid-registration-token","errorCode":null,"errorMessage":"Invalid registration token","messagePattern":"Invalid registration token","errorType":"exception","errorClass":"CloudWorkspaceConnectionError","httpStatus":400,"severity":"error","filePath":"apps/meteor/server/lib/cloud/connectWorkspace.ts","lineNumber":54,"sourceCode":"\t\t} catch (error) {\n\t\t\tthrow new CloudWorkspaceConnectionError(`Failed to connect to Rocket.Chat Cloud: ${response.statusText}`);\n\t\t}\n\t}\n\n\tconst payload = await response.json();\n\n\tif (!payload) {\n\t\treturn undefined;\n\t}\n\n\treturn payload;\n};\n\nexport async function connectWorkspace(token: string) {\n\tassertNotOfflineLicense();\n\n\tif (!token) {\n\t\tthrow new CloudWorkspaceConnectionError('Invalid registration token');\n\t}\n\n\ttry {\n\t\tconst redirectUri = getRedirectUri();\n\n\t\tconst body = {\n\t\t\temail: settings.get<string>('Organization_Email'),\n\t\t\tclient_name: settings.get<string>('Site_Name'),\n\t\t\tredirect_uris: [redirectUri],\n\t\t};\n\n\t\tconst payload = await fetchRegistrationDataPayload({ token, body });\n\n\t\tif (!payload) {\n\t\t\treturn false;\n\t\t}\n\n\t\tawait saveRegistrationData(payload);","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/cloud/connectWorkspace.ts#L36-L72","documentation":"connectWorkspace's first guard: a falsy token (empty string, undefined, null) throws CloudWorkspaceConnectionError('Invalid registration token') before any network request is made. This is pure input validation on the cloud registration entry point — no cloud call has happened yet when you see it.","triggerScenarios":"Calling cloud:connectWorkspace / connectWorkspace with an empty token: the Setup Wizard step submitting before the token was pasted, or automation passing an undefined variable.","commonSituations":"User clicks Register without pasting the token from the cloud console; frontend form state cleared; scripts invoking the method with a missing argument.","solutions":["Get the registration token from the Rocket.Chat Cloud console and paste it exactly.","Validate the token is a non-empty string before invoking the method.","Check the client code is not stripping or mutating the token field before submission."],"exampleFix":"// before\nawait Meteor.callAsync('cloud:connectWorkspace', '');\n\n// after\nconst token = tokenInput.trim();\nif (!token) throw new Error('Paste the registration token from cloud.rocket.chat');\nawait Meteor.callAsync('cloud:connectWorkspace', token);","handlingStrategy":"validation","validationCode":"const isValidRegistrationToken = (token: unknown): token is string =>\n  typeof token === 'string' && token.trim().length > 0;\n\nif (!isValidRegistrationToken(token)) {\n  throw new Error('paste the registration token from the Rocket.Chat Cloud console');\n}\nawait Meteor.callAsync('cloud:connectWorkspace', token.trim());","typeGuard":"const isValidRegistrationToken = (token: unknown): token is string =>\n  typeof token === 'string' && token.trim().length > 0;","tryCatchPattern":"try {\n  await Meteor.callAsync('cloud:connectWorkspace', token);\n} catch (e) {\n  if (e instanceof CloudWorkspaceConnectionError && e.message === 'Invalid registration token') {\n    // client-side bug: token never reached the method — fix the form, not the cloud\n  }\n  throw e;\n}","preventionTips":["Disable the Register submit action until the token field is non-empty.","Trim pasted tokens; tokens copied from consoles often carry trailing whitespace.","Never call cloud:connectWorkspace from automation without asserting the token argument first."],"tags":["rocket-chat","cloud","registration","input-validation"],"backgroundTag":"missing-registration-token","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}