{"record":{"id":"db1cc87e5b804736","repo":"RocketChat/Rocket.Chat","slug":"failed-to-connect-to-rocket-chat-cloud-response-db1cc8","errorCode":null,"errorMessage":"Failed to connect to Rocket.Chat Cloud: ${response.statusText}","messagePattern":"Failed to connect to Rocket\\.Chat Cloud: (.+?)","errorType":"exception","errorClass":"CloudWorkspaceConnectionError","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/cloud/syncWorkspace/legacySyncWorkspace.ts","lineNumber":42,"sourceCode":"}): Promise<Cloud.WorkspaceSyncPayload | undefined> => {\n\tconst workspaceRegistrationClientUri = settings.get<string>('Cloud_Workspace_Registration_Client_Uri');\n\tconst response = await fetch(`${workspaceRegistrationClientUri}/client`, {\n\t\tmethod: 'POST',\n\t\theaders: {\n\t\t\tAuthorization: `Bearer ${token}`,\n\t\t},\n\t\tbody: workspaceRegistrationData,\n\t\ttimeout: 5000,\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\ttry {\n\t\t\tconst { error } = await response.json();\n\t\t\tthrow new CloudWorkspaceConnectionError(`Failed to connect to Rocket.Chat Cloud: ${error}`);\n\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\tconst result = Cloud.WorkspaceSyncPayloadSchema.safeParse(payload);\n\n\tif (!result.success) {\n\t\tthrow new CloudWorkspaceConnectionError('Invalid response from Rocket.Chat Cloud', {\n\t\t\tcause: z.prettifyError(result.error),\n\t\t});\n\t}\n\n\treturn result.data;","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/cloud/syncWorkspace/legacySyncWorkspace.ts#L24-L60","documentation":"The same non-ok branch in the legacy sync fetch, but the response body is not JSON, so the error falls back to the HTTP statusText. Something other than the cloud API answered the sync request — typically a proxy, a firewall interception page, or a wrong Cloud_Url returning an HTML error.","triggerScenarios":"Proxy/WAF/TLS-inspection interception of the cloud sync request, a misconfigured Cloud_Url served by a generic web server, or gateway 502/503 errors during legacy workspace sync.","commonSituations":"Corporate egress proxies; Cloud_Url typos; cloud maintenance windows; gateway timeouts returning HTML error pages.","solutions":["From the server, curl the cloud sync endpoint to see the raw response and who produced it.","Allowlist Cloud_Url on proxies/firewalls and exempt it from TLS inspection.","Correct the Cloud_Url setting.","Retry outside maintenance windows and upgrade off the deprecated legacy sync."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const probe = await fetch(`${cloudUrl}/api/v2/register/workspace/sync`, { method: 'OPTIONS' });\nif (!probe.ok && !probe.headers.get('content-type')?.includes('json')) {\n  throw new Error('a non-cloud intermediary is answering — fix proxy/Cloud_Url before syncing');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await legacySyncWorkspace();\n} catch (e) {\n  if (e instanceof CloudWorkspaceConnectionError && /Gateway|Unavailable|Forbidden|Found/.test(e.message)) {\n    // infrastructure response, not a cloud app error: inspect proxies and Cloud_Url\n  }\n  throw e;\n}","preventionTips":["Smoke-test the cloud sync endpoint from the server after network changes.","Ensure egress proxies pass cloud responses through untouched (no HTML error injection).","Prefer JSON content-type checks in health probes to catch interception early."],"tags":["rocket-chat","cloud","proxy","http-status","sync"],"backgroundTag":"http-non-json-error-response","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}