{"record":{"id":"1462a73b32cb259f","repo":"RocketChat/Rocket.Chat","slug":"custom-fields-not-enabled","errorCode":null,"errorMessage":"Custom fields not enabled","messagePattern":"Custom fields not enabled","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"apps/meteor/server/lib/messaging/validateCustomMessageFields.ts","lineNumber":35,"sourceCode":"\t},\n\t{ maxAge: 1000 * 60 },\n);\n\nexport const validateCustomMessageFields = ({\n\tcustomFields,\n\tmessageCustomFieldsEnabled,\n\tmessageCustomFields,\n}: {\n\tcustomFields: Record<string, any>;\n\tmessageCustomFieldsEnabled: boolean;\n\tmessageCustomFields: string;\n}) => {\n\t// get the json schema for the custom fields of the message and validate it using ajv\n\t// if the validation fails, throw an error\n\t// if there are no custom fields, the message object remains unchanged\n\n\tif (messageCustomFieldsEnabled !== true) {\n\t\tthrow new Error('Custom fields not enabled');\n\t}\n\n\tconst validate = customFieldsValidate(messageCustomFields);\n\tif (!validate(customFields)) {\n\t\tthrow new Error('Invalid custom fields');\n\t}\n};\n","sourceCodeStart":17,"sourceCodeEnd":43,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/messaging/validateCustomMessageFields.ts#L17-L43","documentation":"validateCustomMessageFields requires messageCustomFieldsEnabled === true (the Message_CustomFields_Enabled workspace setting); otherwise it throws a plain Error 'Custom fields not enabled'. Any send/update path that forwards message.customFields into validation will fail on workspaces where the custom-fields feature is switched off.","triggerScenarios":"Calling sendMessage or updateMessage with a customFields payload while Message_CustomFields_Enabled is false (it defaults to false); integrations assuming the feature is on because Message_CustomFields is configured.","commonSituations":"Setting the schema (Message_CustomFields) but forgetting to enable the toggle; deploying an integration to a workspace where the feature was never turned on; assuming enabled-by-default.","solutions":["Enable Message_CustomFields_Enabled in Administration -> Message if custom fields are wanted","Clients/integrations: check the setting before attaching customFields to messages","Omit customFields entirely on workspaces where the feature is off"],"exampleFix":"// before - integration always sends custom fields\nawait sendMessage(user, { ...message, customFields: { ticketId } }, room);\n\n// after - only attach them when the workspace supports it\nconst payload = customFieldsEnabled\n  ? { ...message, customFields: { ticketId } }\n  : message;\nawait sendMessage(user, payload, room);","handlingStrategy":"validation","validationCode":"// Check the public setting before attaching custom fields\nconst enabled = settingsCollection.findOne('_Message_CustomFields_Enabled')?.value === true;\nconst payload = enabled && customFields ? { ...message, customFields } : message;\nawait sendMessage(user, payload, room);","typeGuard":null,"tryCatchPattern":"try {\n  await sendMessage(user, { ...message, customFields }, room);\n} catch (e) {\n  if (e instanceof Error && e.message === 'Custom fields not enabled') {\n    // strip customFields and resend without them, or surface the config gap\n    await sendMessage(user, message, room);\n  }\n}","preventionTips":["Check Message_CustomFields_Enabled before building payloads with customFields","Watch settings-change events so feature flags are never stale","Document integration prerequisites: both the toggle and the schema must be configured"],"tags":["custom-fields","settings","feature-flag","messaging"],"backgroundTag":"feature-disabled-by-setting","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}