RocketChat/Rocket.Chat · warning
Invalid customFieldsToShowInUserInfo value
Error message
Invalid customFieldsToShowInUserInfo value
What it means
The Accounts_CustomFieldsToShowInUserInfo setting must be a JSON array of single-key objects mapping a display label to a custom-field name. useUserCustomFields JSON.parses the setting; if parsing succeeds but the result is not an array (a plain object, number, boolean), it warns and returns undefined, so no custom fields render in the user info view. Malformed JSON fails the earlier JSON.parse catch and returns silently without this warn.
Source
Thrown at apps/meteor/client/hooks/useUserCustomFields.ts:31
}
| undefined;
export const useUserCustomFields = (customFields: CustomField): CustomFieldDisplay[] | undefined => {
const customFieldsToShowSetting = useSetting('Accounts_CustomFieldsToShowInUserInfo');
let customFieldsToShowObj: CustomField[] | undefined;
try {
customFieldsToShowObj = JSON.parse(customFieldsToShowSetting as string);
} catch (error) {
customFieldsToShowObj = undefined;
}
if (!customFieldsToShowObj) {
return undefined;
}
if (!Array.isArray(customFieldsToShowObj)) {
console.warn('Invalid customFieldsToShowInUserInfo value');
return undefined;
}
const customFieldsToShow = customFieldsToShowObj.map((value) => {
if (!value) {
return undefined;
}
const [customFieldLabel] = Object.keys(value);
const [customFieldValue] = Object.values(value);
const fieldValue = customFields?.[customFieldValue];
return { label: customFieldLabel, value: fieldValue !== '' ? fieldValue : undefined };
});
return customFieldsToShow;
};
View on GitHub (pinned to b2c16d5842)
Solutions
- Set the value to a JSON array, e.g. [{"Department": "department"}]
- Use one entry per field: the key is the visible label, the value is the custom field name
- Leave the setting empty to disable the feature cleanly instead of storing a non-array
- Verify the referenced field names exist under Administration -> Accounts -> Custom Fields
Example fix
# before (Accounts_CustomFieldsToShowInUserInfo)
{"Department": "department"}
# after
[{"Department": "department"}, {"Phone": "phone"}] Defensive patterns
Strategy: validation
Validate before calling
const parseCustomFieldsToShow = (raw: unknown): Array<Record<string, string>> | null => {
if (typeof raw !== 'string' || raw.trim() === '') return null;
try {
const parsed: unknown = JSON.parse(raw);
return Array.isArray(parsed) ? (parsed as Array<Record<string, string>>) : null;
} catch {
return null;
}
}; Type guard
const isCustomFieldsToShow = (v: unknown): v is Array<Record<string, string>> => Array.isArray(v) && v.every((entry) => !!entry && typeof entry === 'object' && !Array.isArray(entry) && Object.keys(entry).length === 1);
Prevention
- Validate the setting on save in the admin UI, not on every client read
- Document the exact array shape next to the setting - the label-key/field-value order is easy to invert
- Prefer an empty value over ad-hoc placeholders to disable the feature
When it happens
Trigger: An admin saves a value like {"Department":"department"} (object root, not array), or true / 42 - any valid JSON whose root is not an array triggers the warn.
Common situations: Copy-pasting a single-field example without wrapping it in [ ]; migrating from an older setting format; placeholder values that happen to be valid non-array JSON.
Related errors
- error-invalid-customfield-json
- error-invalid-customfield-json
- The JSON specified for "Accounts_CustomFields" is invalid. T
- error-push-disabled
- error-not-allowed
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/d0e2a9273c7db6fc.
Report an issue: GitHub.