{"record":{"id":"a09168020aaefc8a","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-setting-value","errorCode":"error-invalid-setting-value","errorMessage":"Value for setting ${setting._id} must be greater than or equal to ${setting.minValue}","messagePattern":"Value for setting (.+?) must be greater than or equal to (.+?)","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/settings/checkSettingValueBonds.ts","lineNumber":14,"sourceCode":"import type { ISetting } from '@rocket.chat/core-typings';\nimport { Meteor } from 'meteor/meteor';\n\nconst hasNumericBounds = (setting: ISetting): setting is ISetting & { minValue?: number; maxValue?: number } => {\n\treturn setting.type === 'int' || setting.type === 'range';\n};\n\nexport const checkSettingValueBounds = (setting: ISetting, value?: ISetting['value']): void => {\n\tif (!hasNumericBounds(setting) || !value) {\n\t\treturn;\n\t}\n\n\tif (setting.minValue !== undefined && Number(value) < setting.minValue) {\n\t\tthrow new Meteor.Error(\n\t\t\t'error-invalid-setting-value',\n\t\t\t`Value for setting ${setting._id} must be greater than or equal to ${setting.minValue}`,\n\t\t\t{ method: 'saveSettings' },\n\t\t);\n\t}\n\n\tif (setting.maxValue !== undefined && Number(value) > setting.maxValue) {\n\t\tthrow new Meteor.Error(\n\t\t\t'error-invalid-setting-value',\n\t\t\t`Value for setting ${setting._id} must be less than or equal to ${setting.maxValue}`,\n\t\t\t{ method: 'saveSettings' },\n\t\t);\n\t}\n};\n","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/settings/checkSettingValueBonds.ts#L1-L29","documentation":"Admin settings save (saveSettings method -> saveSettingsBulk -> checkSettingValueBounds) enforces declared numeric bounds on settings of type 'int' and 'range'. If the submitted value is below the setting's minValue, the save aborts with Meteor error code 'error-invalid-setting-value' and a message naming the setting id and the required minimum. The error details carry { method: 'saveSettings' }.","triggerScenarios":"POSTing to the saveSettings method/API with a numeric setting below its declared minimum, e.g. -10 for a setting whose minValue is 0; automation scripts writing config values that were valid on an older version whose bounds later tightened.","commonSituations":"Version upgrades that introduce or tighten minValue on existing settings; configurations imported from other workspaces; scripts copying values between environments with different setting definitions.","solutions":["Fetch the setting definition (minValue ships with setting metadata) and submit a value >= minValue","Clamp user or admin input to [minValue, maxValue] in the client or script before calling saveSettings","If the bound itself is wrong for your deployment, change the setting definition rather than bypassing validation","Read the error message: it names the exact setting id and required minimum"],"exampleFix":"// before\nMeteor.call('saveSettings', [{ _id: 'API_User_Limit', value: -5 }]);\n// -> error-invalid-setting-value: must be greater than or equal to 0\n\n// after\nconst s = Settings.findOneById('API_User_Limit');\nconst value = Math.max(s.minValue ?? -Infinity, -5);\nMeteor.call('saveSettings', [{ _id: 'API_User_Limit', value }]);","handlingStrategy":"validation","validationCode":"const setting = Settings.findOneById(settingId);\nconst value = Math.max(setting.minValue ?? -Infinity, rawValue);\nMeteor.call('saveSettings', [{ _id: settingId, value }]);","typeGuard":"const isWithinBounds = (s: ISetting & { minValue?: number; maxValue?: number }, v: number): boolean =>\n\t(s.minValue === undefined || v >= s.minValue) && (s.maxValue === undefined || v <= s.maxValue);","tryCatchPattern":"catch (err) {\n\tif (err instanceof Meteor.Error && err.error === 'error-invalid-setting-value') {\n\t\t// message names the setting and bound; correct the value and re-save\n\t} else throw err;\n}","preventionTips":["Fetch setting metadata (minValue, maxValue) and validate before submit","Clamp admin-form inputs to declared bounds","Save settings in small batches so one bad value does not abort unrelated changes"],"tags":["settings","validation","admin","bounds","meteor-method"],"backgroundTag":"setting-value-out-of-range","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}