RocketChat/Rocket.Chat · error · CloudWorkspaceAccessTokenEmptyError

Workspace access token is empty

Error message

Workspace access token is empty

What it means

Thrown by syncCloudData() when the workspace reports as registered with Rocket.Chat Cloud but getWorkspaceAccessToken(true) resolves to an empty string. getWorkspaceAccessToken returns '' when an offline license is active or when fetching a new token from Cloud fails in its non-throwing mode, so the sync run has no bearer token and aborts before building the registration payload.

Source

Thrown at apps/meteor/server/lib/cloud/syncWorkspace/syncCloudData.ts:22

import { fetchWorkspaceSyncPayload } from './fetchWorkspaceSyncPayload';
import { CloudWorkspaceAccessError } from '../../../../lib/errors/CloudWorkspaceAccessError';
import { CloudWorkspaceRegistrationError } from '../../../../lib/errors/CloudWorkspaceRegistrationError';
import { callbacks } from '../../callbacks';
import { SystemLogger } from '../../logger/system';
import { buildWorkspaceRegistrationData } from '../buildRegistrationData';
import { CloudWorkspaceAccessTokenEmptyError, getWorkspaceAccessToken } from '../getWorkspaceAccessToken';
import { retrieveRegistrationStatus } from '../retrieveRegistrationStatus';

export async function syncCloudData() {
	try {
		const { workspaceRegistered } = await retrieveRegistrationStatus();
		if (!workspaceRegistered) {
			throw new CloudWorkspaceRegistrationError('Workspace is not registered');
		}

		const token = await getWorkspaceAccessToken(true);
		if (!token) {
			throw new CloudWorkspaceAccessTokenEmptyError();
		}

		const workspaceRegistrationData = await buildWorkspaceRegistrationData(undefined);

		const {
			license,
			removeLicense = false,
			cloudSyncAnnouncement,
		} = await fetchWorkspaceSyncPayload({
			token,
			data: workspaceRegistrationData,
		});

		await Settings.updateValueById('Cloud_Sync_Announcement_Payload', JSON.stringify(cloudSyncAnnouncement ?? null));

		if (removeLicense) {
			await callbacks.run('workspaceLicenseRemoved');
		} else {

View on GitHub (pinned to b2c16d5842)

Solutions

  1. If an offline license is intentional, remove the stale cloud registration data so retrieveRegistrationStatus no longer reports registered
  2. Verify outbound HTTPS connectivity to Rocket.Chat Cloud from the server, then let the sync retry and fetch a fresh token
  3. Re-register the workspace (Administration > Connectivity Services) so valid WorkspaceCredentials are stored
  4. Check the WorkspaceCredentials collection and server logs for silent token-fetch failures if the issue persists

Example fix

// before
const token = await getWorkspaceAccessToken(true);
if (!token) {
  throw new CloudWorkspaceAccessTokenEmptyError();
}

// after: only sync when a token is actually obtainable, otherwise surface re-registration
const token = await getWorkspaceAccessToken(true);
if (!token) {
  await updateRegistrationStatus();
  return; // skip this sync cycle instead of throwing
Defensive patterns

Strategy: validation

Validate before calling

import { getWorkspaceAccessToken } from './getWorkspaceAccessToken';
import { retrieveRegistrationStatus } from './retrieveRegistrationStatus';

const { workspaceRegistered } = await retrieveRegistrationStatus();
const token = await getWorkspaceAccessToken(true);
if (workspaceRegistered && !token) {
  // skip the sync cycle and surface a re-registration prompt instead of throwing
}

Try / catch

try {
  await syncCloudData();
} catch (err) {
  if (err instanceof CloudWorkspaceAccessTokenEmptyError) {
    // token unobtainable: schedule re-registration, do not retry blindly
    return;
  }
  throw err;
}

Prevention

When it happens

Trigger: The periodic workspace sync (or a manual sync call) runs when retrieveRegistrationStatus() says registered, but the WorkspaceCredentials cache is empty/expired and the token request to Cloud fails silently, or License.hasOfflineLicense() makes getWorkspaceAccessToken return '' unconditionally.

Common situations: Offline license installed on a workspace that still carries cloud registration data; Cloud unreachable (firewall/DNS) so token renewal never succeeds; registration records partially present after a database restore or migration.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18). Data as JSON: /api/errors/c53037261868b1e9. Report an issue: GitHub.