{"record":{"id":"35a65b5def7ee1f9","repo":"RocketChat/Rocket.Chat","slug":"failed-type-validation","errorCode":null,"errorMessage":"failed type validation","messagePattern":"failed type validation","errorType":"http","errorClass":"CloudWorkspaceConnectionError","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/cloud/syncWorkspace/fetchWorkspaceSyncPayload.ts","lineNumber":36,"sourceCode":"\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":18,"sourceCodeEnd":43,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/cloud/syncWorkspace/fetchWorkspaceSyncPayload.ts#L18-L43","documentation":"Cloud answered the sync request with HTTP 200, but the JSON body failed Cloud.WorkspaceSyncResponseSchema.safeParse (zod): the returned shape does not match what this server build expects for fields like license, removeLicense, or cloudSyncAnnouncement. The error's cause contains z.prettifyError output pinpointing the failing fields.","triggerScenarios":"Cloud ships a response whose fields are renamed, missing, or differently typed relative to the local zod schema — typically a server build older (or newer) than the Cloud API — or an intermediary returns a different JSON document with a 200 status.","commonSituations":"Downgraded or fork-pinned server versions lagging the Cloud API; a proxy or captive portal injecting a JSON body; Cloud mid-deployment emitting a transitional payload.","solutions":["Update the Rocket.Chat server to a current release so WorkspaceSyncResponseSchema matches Cloud's payload","Inspect err.cause (the zod prettified report) to see exactly which field mismatched, and report it if both sides are on current versions","Remove or verify any HTTPS proxy in front of the server that could alter response bodies"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const payload = await fetchWorkspaceSyncPayload({ token, data });\n} catch (err) {\n  if (err instanceof CloudWorkspaceConnectionError && err.message === 'failed type validation') {\n    // payload/schema skew: log err.cause (zod report), keep last known good state, don't crash the job\n    logger.warn({ msg: 'Cloud sync schema mismatch', cause: err.cause });\n    return;\n  }\n  throw err;\n}","preventionTips":["Keep the server updated so WorkspaceSyncResponseSchema tracks Cloud's payload","Always log err.cause — it names the exact mismatched field","Design periodic sync consumers to tolerate one failed validation cycle without data loss"],"tags":["cloud","zod","schema-validation","sync"],"backgroundTag":"schema-validation-failed","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}