{"record":{"id":"cdfa107e8f5db21e","repo":"RocketChat/Rocket.Chat","slug":"invalid-idle-time-limit-value","errorCode":"invalid-idle-time-limit-value","errorMessage":"Invalid idleTimeLimit","messagePattern":"Invalid idleTimeLimit","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/users/saveUserPreferences.ts","lineNumber":210,"sourceCode":"\tif (settings.language != null) {\n\t\tawait Users.setLanguage(user._id, settings.language);\n\t}\n\n\t// utcOffset lives at the user-document root (not under settings.preferences)\n\tif (settings.utcOffset != null) {\n\t\tawait Users.setUtcOffset(user._id, settings.utcOffset);\n\t\tdelete settings.utcOffset;\n\t}\n\n\t// Keep compatibility with old values\n\tif (settings.emailNotificationMode === 'all') {\n\t\tsettings.emailNotificationMode = 'mentions';\n\t} else if (settings.emailNotificationMode === 'disabled') {\n\t\tsettings.emailNotificationMode = 'nothing';\n\t}\n\n\tif (settings.idleTimeLimit != null && settings.idleTimeLimit < 60) {\n\t\tthrow new Meteor.Error('invalid-idle-time-limit-value', 'Invalid idleTimeLimit');\n\t}\n\n\tconst requested = settings.statusVisibilityDenied?.filter((username) => username !== user.username);\n\tconst denied = requested ? await resolveUsersByUsernames(requested) : undefined;\n\n\tif (denied) {\n\t\tsettings.statusVisibilityDenied = denied.usernames;\n\t}\n\n\tawait Users.setPreferences(user._id, denied ? { ...settings, statusVisibilityDenied: denied.ids } : settings);\n\n\tconst diff = (Object.keys(settings) as (keyof UserPreferences)[]).reduce<Record<string, any>>((data, key) => {\n\t\tdata[`settings.preferences.${key}`] = settings[key];\n\n\t\treturn data;\n\t}, {});\n\n\tvoid notifyOnUserChange({","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b263243745917337314259cf987c0e989cf0cdc9/apps/meteor/server/meteor-methods/users/saveUserPreferences.ts#L192-L228","documentation":"Thrown by saveUserPreferences (DDP method behind POST /v1/users.setPreferences) when the submitted idleTimeLimit preference is present (not null/undefined) and is below 60. The value is in seconds and 60 is the enforced minimum so idle detection cannot flap sub-minute. Note the check only rejects the low bound - non-numeric values are caught earlier by argument checking.","triggerScenarios":"saveUserPreferences({ idleTimeLimit: 30 }); UI number inputs with min=0 allowing values under 60; units confusion - sending milliseconds (e.g. 30000 as '30s') is accepted but sending 30 meaning 30s is rejected.","commonSituations":"Preference forms without a lower bound; importing preferences from another system that stores idle minutes or milliseconds; tests using tiny values for fast idle.","solutions":["Clamp the value before saving: idleTimeLimit = Math.max(60, value).","Set min={60} (and step=60) on the form input and document the unit as seconds.","Omit the key entirely to keep the current value instead of sending a small placeholder like 0."],"exampleFix":"// before\nawait Meteor.callAsync('saveUserPreferences', { idleTimeLimit: seconds < 60 ? seconds : seconds }); // 30 -> throws\n\n// after\nconst idleTimeLimit = Math.max(60, Math.round(seconds));\nawait Meteor.callAsync('saveUserPreferences', { idleTimeLimit });","handlingStrategy":"validation","validationCode":"const MIN_IDLE = 60; // seconds, enforced server-side\nif (prefs.idleTimeLimit != null && prefs.idleTimeLimit < MIN_IDLE) {\n  prefs.idleTimeLimit = MIN_IDLE; // or reject with an inline form error\n}\nawait Meteor.callAsync('saveUserPreferences', prefs);","typeGuard":"const isValidIdleTimeLimit = (v: unknown): v is number =>\n  typeof v === 'number' && Number.isFinite(v) && v >= 60;","tryCatchPattern":"try {\n  await Meteor.callAsync('saveUserPreferences', prefs);\n} catch (e) {\n  if ((e as Meteor.Error).error === 'invalid-idle-time-limit-value') {\n    setInlineError('idleTimeLimit', 'Must be at least 60 seconds');\n    await Meteor.callAsync('saveUserPreferences', { ...prefs, idleTimeLimit: 60 });\n  }\n}","preventionTips":["Set min={60} on the idle-time-limit input and label the unit as seconds","Clamp before save: Math.max(60, value)","Omit the key rather than sending 0 as a placeholder"],"tags":["preferences","validation","value-out-of-range","meteor-method"],"backgroundTag":"value-out-of-range","analyzedSha":"b263243745917337314259cf987c0e989cf0cdc9","analyzedAt":"2026-08-21T15:01:34.830Z","contentChangedAt":"2026-08-21T15:01:34.830Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}