{"record":{"id":"0f7feae5bfa08cf5","repo":"RocketChat/Rocket.Chat","slug":"failed-to-connect-to-rocket-chat-cloud-error-0f7fea","errorCode":null,"errorMessage":"Failed to connect to Rocket.Chat Cloud: ${error}","messagePattern":"Failed to connect to Rocket\\.Chat Cloud: (.+?)","errorType":"http","errorClass":"CloudWorkspaceConnectionError","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/cloud/syncWorkspace/fetchWorkspaceSyncPayload.ts","lineNumber":28,"sourceCode":"\tdata,\n}: {\n\ttoken: string;\n\tdata: Cloud.WorkspaceSyncRequestPayload;\n}): Promise<Cloud.WorkspaceSyncResponse> {\n\tconst workspaceRegistrationClientUri = settings.get<string>('Cloud_Workspace_Registration_Client_Uri');\n\tconst response = await fetch(`${workspaceRegistrationClientUri}/sync`, {\n\t\tmethod: 'POST',\n\t\theaders: {\n\t\t\tAuthorization: `Bearer ${token}`,\n\t\t},\n\t\tbody: data,\n\t\t// SECURITY: the URL is a default hardcoded value or an envvar/setting set by an admin. It's safe to disable this check.\n\t\tignoreSsrfValidation: true,\n\t});\n\n\tif (!response.ok) {\n\t\tconst { error } = await response.json();\n\t\tthrow new CloudWorkspaceConnectionError(`Failed to connect to Rocket.Chat Cloud: ${error}`);\n\t}\n\n\tconst payload = await response.json();\n\n\tconst result = Cloud.WorkspaceSyncResponseSchema.safeParse(payload);\n\n\tif (!result.success) {\n\t\tthrow new CloudWorkspaceConnectionError('failed type validation', {\n\t\t\tcause: z.prettifyError(result.error),\n\t\t});\n\t}\n\n\treturn result.data;\n}\n","sourceCodeStart":10,"sourceCodeEnd":43,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/cloud/syncWorkspace/fetchWorkspaceSyncPayload.ts#L10-L43","documentation":"fetchWorkspaceSyncPayload POSTs to {workspaceRegistrationClientUri}/sync with the workspace bearer token; when Cloud answers with a non-2xx status the JSON body's error field is embedded into this CloudWorkspaceConnectionError. The text after the colon is the upstream reason reported by Cloud, not a local message.","triggerScenarios":"Cloud returns 401/403 because the workspace token was revoked or is stale, 400 because the registration payload is rejected, or any 5xx during a Cloud-side incident — response.ok is false and the body parses as { error }.","commonSituations":"Workspace re-registered elsewhere so the old token was invalidated; Cloud API temporarily degraded; a TLS-intercepting proxy returning error statuses; version skew between an old server build and the current Cloud API.","solutions":["Read the embedded Cloud error text: unauthorized-style messages mean the stored token is stale — re-register or re-login the workspace","Confirm the workspace registration client URL setting points at the official Cloud endpoint and is not rewritten by a proxy","If the embedded error indicates a Cloud-side failure, retry the sync later (the job is periodic)","Update the Rocket.Chat server if a payload contract change is causing rejections"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await fetchWorkspaceSyncPayload({ token, data: workspaceRegistrationData });\n} catch (err) {\n  if (err instanceof CloudWorkspaceConnectionError && /unauthorized|forbidden/i.test(err.message)) {\n    // token stale: re-register workspace; do not retry with the same token\n  } else if (err instanceof CloudWorkspaceConnectionError) {\n    // transient upstream failure: let the periodic sync retry later\n  } else {\n    throw err;\n  }\n}","preventionTips":["Re-register the workspace after any Cloud-side token revocation","Keep the cloud registration URL setting pointed at the official endpoint, unmodified by proxies","Treat the sync job as self-healing: log and retry on transient upstream errors"],"tags":["cloud","http","sync","network"],"backgroundTag":"upstream-api-error","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}