{"record":{"id":"47c14f7765592723","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-setting-value-47c14f","errorCode":"error-invalid-setting-value","errorMessage":"Invalid setting value ${value}","messagePattern":"Invalid setting value (.+?)","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/settings/lib/saveSettingsBulk.ts","lineNumber":27,"sourceCode":"import { getSettingPermissionId } from '../../../app/authorization/lib';\nimport { hasPermissionAsync } from '../../lib/authorization/hasPermission';\nimport { notifyOnSettingChangedById } from '../../lib/notifyListener';\nimport { validateSettingRules } from '../../lib/settingValidationRules';\nimport { disableCustomScripts } from '../../lib/shared/disableCustomScripts';\nimport { checkSettingValueBounds } from '../checkSettingValueBonds';\n\nconst validJSON = Match.Where((value: string) => {\n\ttry {\n\t\tvalue === '' || JSON.parse(value);\n\t\treturn true;\n\t} catch (_) {\n\t\tthrow new Meteor.Error('Invalid JSON provided');\n\t}\n});\n\nconst checkInteger = (value: ISetting['value']) => {\n\tif (!Number.isInteger(value)) {\n\t\tthrow new Meteor.Error('error-invalid-setting-value', `Invalid setting value ${value}`, {\n\t\t\tmethod: 'saveSettings',\n\t\t});\n\t}\n};\n\nexport type SaveSettingsAudit = {\n\tusername: string;\n\tip: string;\n\tuseragent: string;\n};\n\nexport const saveSettingsBulk = async (\n\tuid: string,\n\tparams: { _id: ISetting['_id']; value: ISetting['value']; editor?: ISettingColor['editor'] }[],\n\taudit: SaveSettingsAudit,\n): Promise<void> => {\n\tconst settingsNotAllowed: ISetting['_id'][] = [];\n","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/settings/lib/saveSettingsBulk.ts#L9-L45","documentation":"For settings of type 'int', 'timespan' or 'range', saveSettingsBulk first checks the payload value is a Number (meteor check) and then that Number.isInteger(value) holds. Any non-integer - a float like 50.5, a numeric string like '50', null or undefined - fails with 'error-invalid-setting-value' and the message 'Invalid setting value <value>'. This is a payload type error, not a bounds problem.","triggerScenarios":"REST/API callers sending numbers as strings ('25' instead of 25); UI code passing a parsed float (from an input element or formula) without rounding; scripts reusing values from configs where the number was serialized as a string.","commonSituations":"Integrations written against loosely typed JSON; client form inputs returning strings; values round-tripped through systems that stringify numbers (URL query params, CSV exports).","solutions":["Send integer JSON numbers, never strings: value 30 not value '30'","Round or Math.trunc float inputs before submitting (50.5 -> 50 or 51 as appropriate)","Validate the payload client-side with Number.isInteger before calling saveSettings","Check the error message - it prints the offending value, making string-typed numbers obvious"],"exampleFix":"// before\nawait fetch('/api/v1/settings', { body: JSON.stringify([{ _id: 'API_User_Limit', value: \"25\" }]) });\n// -> error-invalid-setting-value: Invalid setting value 25\n\n// after\nawait fetch('/api/v1/settings', { body: JSON.stringify([{ _id: 'API_User_Limit', value: 25 }]) });","handlingStrategy":"type-guard","validationCode":"if (typeof value !== 'number' || !Number.isInteger(value)) {\n\tvalue = Math.round(Number(value)); // coerce string or float input to an integer number\n}\nMeteor.call('saveSettings', [{ _id: settingId, value }]);","typeGuard":"const isIntegerSettingValue = (v: unknown): v is number => typeof v === 'number' && Number.isInteger(v);","tryCatchPattern":"catch (err) {\n\tif (err instanceof Meteor.Error && err.error === 'error-invalid-setting-value' && /Invalid setting value/.test(err.reason)) {\n\t\t// value was a string or float: fix the payload type and retry\n\t} else throw err;\n}","preventionTips":["Always send numbers as JSON numbers, never strings","Coerce form inputs with Number() then Math.round before submit","Unit-test settings payloads with typeof checks on int, timespan and range fields"],"tags":["settings","validation","type-mismatch","meteor-method"],"backgroundTag":"invalid-type-value","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"}