{"record":{"id":"dcd082b19fc3037b","repo":"RocketChat/Rocket.Chat","slug":"error-setting-validation-failed-dcd082","errorCode":"error-setting-validation-failed","errorMessage":"error.message","messagePattern":"error\\.message","errorType":"validation","errorClass":"Meteor.Error","httpStatus":null,"severity":"warning","filePath":"apps/meteor/server/meteor-methods/settings/saveSettings.ts","lineNumber":46,"sourceCode":"\t) {\n\t\tmethodDeprecationLogger.method('saveSettings', '9.0.0', '/v1/settings');\n\n\t\tconst uid = Meteor.userId();\n\t\tif (uid === null) {\n\t\t\tthrow new Meteor.Error('error-action-not-allowed', 'Editing settings is not allowed', {\n\t\t\t\tmethod: 'saveSetting',\n\t\t\t});\n\t\t}\n\n\t\ttry {\n\t\t\tawait saveSettingsBulk(uid, params, {\n\t\t\t\tusername: (await Meteor.userAsync())!.username!,\n\t\t\t\tip: this.connection.clientAddress || '',\n\t\t\t\tuseragent: this.connection.httpHeaders['user-agent'] || '',\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (error instanceof SettingValidationError) {\n\t\t\t\tthrow new Meteor.Error('error-setting-validation-failed', error.message);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\n\t\treturn true;\n\t}, {}),\n});\n","sourceCodeStart":28,"sourceCodeEnd":54,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/settings/saveSettings.ts#L28-L54","documentation":"The bulk `saveSettings` method delegates to `saveSettingsBulk`, which validates every entry (type checks per setting type, integer/bounds checks, JSON schema for code settings) and then runs `validateSettingRules(params)` over the whole batch before any write. Any `SettingValidationError` bubbles up as `error-setting-validation-failed` with message `<Setting_Id>_Invalid`, and because validation precedes all writes the batch is all-or-nothing.","triggerScenarios":"Calling `saveSettings` with an array where at least one entry fails its validation: a JSON `code` setting with schema-invalid content, a value rejected by a setting's `validation` filter, or (from the bulk path) a non-integer int/timespan/range value. The failing setting is named by the `<Setting_Id>_Invalid` message.","commonSituations":"Admin UI forms that submit many settings at once and fail opaquely; settings-as-code pipelines pushing one bad value that rolls back the whole batch; cross-setting rules that only trip when several values change together.","solutions":["Read the `<Setting_Id>_Invalid` message — it identifies exactly which setting in the batch failed.","Fix or drop that entry and resend; the batch is atomic, so nothing was saved.","When the culprit is unclear, split the batch into individual `saveSetting` calls to isolate failures.","For int/range settings, ensure `Number.isInteger(value)` and respect min/max bounds before sending."],"exampleFix":"// before - one bad entry fails the whole batch\nMeteor.call('saveSettings', [{ _id: 'A', value: 1 }, { _id: 'B', value: '{ bad json' }]);\n\n// after - isolate the offender when the batch rejects\ntry {\n  Meteor.call('saveSettings', batch);\n} catch (e) {\n  if (e.error === 'error-setting-validation-failed') {\n    // e.reason is '<Setting_Id>_Invalid': fix or remove that entry and resend\n  }\n}","handlingStrategy":"try-catch","validationCode":"// pre-check the easy bulk failures locally: integers and JSON payloads\nconst isBulkSaveable = (params: { _id: string; value: any }[]): boolean =>\n  params.every(({ value }) => {\n    if (typeof value === 'number') return Number.isInteger(value);\n    if (typeof value === 'string' && value !== '') { try { JSON.parse(value); } catch { return false; } }\n    return true;\n  });","typeGuard":"const isIntegerSetting = (value: unknown): value is number => typeof value === 'number' && Number.isInteger(value);","tryCatchPattern":"try {\n  await Meteor.callAsync('saveSettings', params);\n} catch (e: any) {\n  if (e?.error === 'error-setting-validation-failed') {\n    // e.reason is '<Setting_Id>_Invalid' - nothing was saved (atomic batch); fix that entry and resend\n  }\n}","preventionTips":["Validate int/timespan/range and JSON values client-side before batching.","Keep batches small so one bad setting does not roll back a large form.","Use the <Setting_Id>_Invalid reason to jump the user to the offending field."],"tags":["meteor","settings","validation","bulk-update"],"backgroundTag":"config-validation-failed","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}