RocketChat/Rocket.Chat · error · Meteor.Error
error-invalid-settings
error-invalid-settings
Error message
Invalid settings field
What it means
saveAutoTranslateSettings validates that `field` is one of exactly two strings: 'autoTranslate' (the on/off toggle, stored as '1'/'0') or 'autoTranslateLanguage' (the per-room target language code). Any other value throws error-invalid-settings. The REST body schema allows any string for field, so ajv does not stop it first.
Source
Thrown at apps/meteor/server/lib/autotranslate/functions/saveSettings.ts:26
export const saveAutoTranslateSettings = async (
userId: string,
rid: string,
field: string,
value: string,
options: { defaultLanguage: string },
) => {
if (!(await hasPermissionAsync(userId, 'auto-translate'))) {
throw new Meteor.Error('error-action-not-allowed', 'Auto-Translate is not allowed', {
method: 'autoTranslate.saveSettings',
});
}
check(rid, String);
check(field, String);
check(value, String);
if (['autoTranslate', 'autoTranslateLanguage'].indexOf(field) === -1) {
throw new Meteor.Error('error-invalid-settings', 'Invalid settings field', {
method: 'saveAutoTranslateSettings',
});
}
const subscription = await Subscriptions.findOneByRoomIdAndUserId(rid, userId);
if (!subscription) {
throw new Meteor.Error('error-invalid-subscription', 'Invalid subscription', {
method: 'saveAutoTranslateSettings',
});
}
let shouldNotifySubscriptionChanged = false;
switch (field) {
case 'autoTranslate':
const room = await Rooms.findE2ERoomById(rid, { projection: { _id: 1 } });
if (room && value === '1') {
throw new Meteor.Error('error-e2e-enabled', 'Enabling auto-translation in E2E encrypted rooms is not allowed', {View on GitHub (pinned to b2c16d5842)
Solutions
- Use only 'autoTranslate' or 'autoTranslateLanguage' as the field value
- Type field as a string union on the caller so invalid values fail at compile time
- Match the value shape: '1'/'0'-style string for autoTranslate, a language code for autoTranslateLanguage
Example fix
// before
call('autoTranslate.saveSettings', rid, 'autoTranslateEnabled', '1', opts); // error-invalid-settings
// after
call('autoTranslate.saveSettings', rid, 'autoTranslate', '1', opts); Defensive patterns
Strategy: type-guard
Validate before calling
const ALLOWED = ['autoTranslate', 'autoTranslateLanguage'] as const;
if (!ALLOWED.includes(field)) {
throw new TypeError(`field must be one of ${ALLOWED.join(', ')}`);
}
await call('autoTranslate.saveSettings', rid, field, value, opts); Type guard
type AutoTranslateField = 'autoTranslate' | 'autoTranslateLanguage'; const isAutoTranslateField = (f: string): f is AutoTranslateField => f === 'autoTranslate' || f === 'autoTranslateLanguage';
Try / catch
try {
await call('autoTranslate.saveSettings', rid, field, value, opts);
} catch (e) {
if (e instanceof Meteor.Error && e.error === 'error-invalid-settings') {
// fix the field name before retrying
} else {
throw e;
}
} Prevention
- Type the field argument as a closed string union on the caller
- Build payloads from a whitelist, never from dynamic user input
- Send '1'/'0' style values for autoTranslate and language codes for autoTranslateLanguage
When it happens
Trigger: Calling autoTranslate.saveSettings with field='autoTranslateEnabled', 'language', or 'autoTranslate_Language'; sending a whole settings object instead of one field name; version skew where an older client sends a field name the server never knew.
Common situations: Hand-rolled API clients guessing field names; copy-paste from other settings methods; payloads built dynamically without a whitelist.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Invalid asset
- error-autotranslate-disabled
- error-action-not-allowed
- error-action-not-allowed
- error-invalid-subscription
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/8670385634f72f41.
Report an issue: GitHub.