RocketChat/Rocket.Chat · warning
The JSON specified for "Accounts_CustomFields" is invalid. T
Error message
The JSON specified for "Accounts_CustomFields" is invalid. The following error was thrown
What it means
A settings watcher builds MongoDB field projections for user data from the Accounts_CustomFields setting: it JSON.parses the value and maps each custom field into publicCustomFields/customCustomFields projections. On parse failure it only logs this warning and keeps the previously computed projections (empty on first run) — the visible symptom is custom fields silently missing from user data / REST API responses even though the raw setting still contains the invalid JSON.
Source
Thrown at apps/meteor/server/lib/users/getFullUserData.ts:68
publicCustomFields = {};
customFields = {};
const value = settingValue?.trim();
if (!value) {
return;
}
try {
const customFieldsOnServer = JSON.parse(value);
Object.keys(customFieldsOnServer).forEach((key) => {
const element = customFieldsOnServer[key];
if (element.public) {
publicCustomFields[`customFields.${key}`] = 1;
}
customFields[`customFields.${key}`] = 1;
});
} catch (e) {
logger.warn({
msg: 'The JSON specified for "Accounts_CustomFields" is invalid. The following error was thrown',
err: e,
});
}
});
const getCustomFields = (canViewAllInfo: boolean): Record<string, 0 | 1> => (canViewAllInfo ? customFields : publicCustomFields);
const getFields = (canViewAllInfo: boolean): Record<string, 0 | 1> => ({
...defaultFields,
...(canViewAllInfo && fullFields),
...getCustomFields(canViewAllInfo),
});
const findTargetUser = (type: string, value: string, opts: any) => {
if (type === 'importId') return Users.findOneByImportId(value, opts);
if (type === 'email') return Users.findOneByEmailAddress(value, opts);
if (type === 'freeSwitchExtension') return Users.findOneByFreeSwitchExtension(value, opts);View on GitHub (pinned to 2a7de45707)
Solutions
- Fix the JSON in Accounts_CustomFields (validate with jsonlint) and save — the watcher recomputes projections immediately
- Cross-check the server logs for the companion 'Invalid Custom Fields' warn from the API layer; both share the root cause
- Prevent recurrence by validating the JSON in CI when deploying settings via env/infrastructure tooling
Defensive patterns
Strategy: validation
Validate before calling
function parseCustomFields(value: string): Record<string, { public?: boolean }> | null {
try {
return JSON.parse(value);
} catch {
return null;
}
}
// null means: keep previous projections and alert the admin, do not silently drop fields Try / catch
try {
const customFieldsOnServer = JSON.parse(value);
/* build projections */
} catch (e) {
logger.warn({ msg: 'The JSON specified for "Accounts_CustomFields" is invalid. The following error was thrown', err: e });
// projections stay at their previous state on purpose
} Prevention
- Validate Accounts_CustomFields JSON before saving, in the UI and in deployment pipelines
- When custom fields vanish from API responses, check this warn first — it is the usual cause
- Fix the value once; both the API watcher and this projection watcher recover together
When it happens
Trigger: Same root cause as the 'Invalid Custom Fields' warn from the API layer: Accounts_CustomFields saved as invalid JSON (trailing commas, single quotes, unquoted keys, truncated value). Fires whenever the watcher recomputes after such a save.
Common situations: Pasted JSON with syntax errors; env-deployed settings with mangled escaping; symptom noticed as customFields absent from users.info / full user data API responses.
Related errors
- error-invalid-customfield-json
- error-invalid-customfield-json
- Invalid customFieldsToShowInUserInfo value
- LDAP_disabled
- invalid-setting
AI-assisted analysis of RocketChat/Rocket.Chat@2a7de45707 (2026-08-18).
Data as JSON: /api/errors/0690ec51315b403c.
Report an issue: GitHub.