RocketChat/Rocket.Chat · error · CloudWorkspaceConnectionError
Invalid registration token
Error message
Invalid registration token
What it means
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.
Source
Thrown at apps/meteor/server/lib/cloud/connectWorkspace.ts:54
} catch (error) {
throw new CloudWorkspaceConnectionError(`Failed to connect to Rocket.Chat Cloud: ${response.statusText}`);
}
}
const payload = await response.json();
if (!payload) {
return undefined;
}
return payload;
};
export async function connectWorkspace(token: string) {
assertNotOfflineLicense();
if (!token) {
throw new CloudWorkspaceConnectionError('Invalid registration token');
}
try {
const redirectUri = getRedirectUri();
const body = {
email: settings.get<string>('Organization_Email'),
client_name: settings.get<string>('Site_Name'),
redirect_uris: [redirectUri],
};
const payload = await fetchRegistrationDataPayload({ token, body });
if (!payload) {
return false;
}
await saveRegistrationData(payload);View on GitHub (pinned to b2c16d5842)
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.
Example fix
// before
await Meteor.callAsync('cloud:connectWorkspace', '');
// after
const token = tokenInput.trim();
if (!token) throw new Error('Paste the registration token from cloud.rocket.chat');
await Meteor.callAsync('cloud:connectWorkspace', token); Defensive patterns
Strategy: validation
Validate before calling
const isValidRegistrationToken = (token: unknown): token is string =>
typeof token === 'string' && token.trim().length > 0;
if (!isValidRegistrationToken(token)) {
throw new Error('paste the registration token from the Rocket.Chat Cloud console');
}
await Meteor.callAsync('cloud:connectWorkspace', token.trim()); Type guard
const isValidRegistrationToken = (token: unknown): token is string => typeof token === 'string' && token.trim().length > 0;
Try / catch
try {
await Meteor.callAsync('cloud:connectWorkspace', token);
} catch (e) {
if (e instanceof CloudWorkspaceConnectionError && e.message === 'Invalid registration token') {
// client-side bug: token never reached the method — fix the form, not the cloud
}
throw e;
} Prevention
- 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.
When it happens
Trigger: Calling cloud:connectWorkspace / connectWorkspace with an empty token: the Setup Wizard step submitting before the token was pasted, or automation passing an undefined variable.
Common situations: User clicks Register without pasting the token from the cloud console; frontend form state cleared; scripts invoking the method with a missing argument.
Related errors
- Failed to connect to Rocket.Chat Cloud: ${error}
- (await response.json()).error
- Failed to fetch registration intent endpoint
- Failed to connect to Rocket.Chat Cloud: ${response.statusTex
- error-invalid-state
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/ded744e5ba0e4578.
Report an issue: GitHub.