{"record":{"id":"d0e2a9273c7db6fc","repo":"RocketChat/Rocket.Chat","slug":"invalid-customfieldstoshowinuserinfo-value","errorCode":null,"errorMessage":"Invalid customFieldsToShowInUserInfo value","messagePattern":"Invalid customFieldsToShowInUserInfo value","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"apps/meteor/client/hooks/useUserCustomFields.ts","lineNumber":31,"sourceCode":"\t  }\n\t| undefined;\n\nexport const useUserCustomFields = (customFields: CustomField): CustomFieldDisplay[] | undefined => {\n\tconst customFieldsToShowSetting = useSetting('Accounts_CustomFieldsToShowInUserInfo');\n\n\tlet customFieldsToShowObj: CustomField[] | undefined;\n\ttry {\n\t\tcustomFieldsToShowObj = JSON.parse(customFieldsToShowSetting as string);\n\t} catch (error) {\n\t\tcustomFieldsToShowObj = undefined;\n\t}\n\n\tif (!customFieldsToShowObj) {\n\t\treturn undefined;\n\t}\n\n\tif (!Array.isArray(customFieldsToShowObj)) {\n\t\tconsole.warn('Invalid customFieldsToShowInUserInfo value');\n\t\treturn undefined;\n\t}\n\n\tconst customFieldsToShow = customFieldsToShowObj.map((value) => {\n\t\tif (!value) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst [customFieldLabel] = Object.keys(value);\n\t\tconst [customFieldValue] = Object.values(value);\n\t\tconst fieldValue = customFields?.[customFieldValue];\n\t\treturn { label: customFieldLabel, value: fieldValue !== '' ? fieldValue : undefined };\n\t});\n\n\treturn customFieldsToShow;\n};\n","sourceCodeStart":13,"sourceCodeEnd":48,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/client/hooks/useUserCustomFields.ts#L13-L48","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"# before (Accounts_CustomFieldsToShowInUserInfo)\n{\"Department\": \"department\"}\n\n# after\n[{\"Department\": \"department\"}, {\"Phone\": \"phone\"}]","handlingStrategy":"validation","validationCode":"const parseCustomFieldsToShow = (raw: unknown): Array<Record<string, string>> | null => {\n  if (typeof raw !== 'string' || raw.trim() === '') return null;\n  try {\n    const parsed: unknown = JSON.parse(raw);\n    return Array.isArray(parsed) ? (parsed as Array<Record<string, string>>) : null;\n  } catch {\n    return null;\n  }\n};","typeGuard":"const isCustomFieldsToShow = (v: unknown): v is Array<Record<string, string>> =>\n  Array.isArray(v) &&\n  v.every((entry) => !!entry && typeof entry === 'object' && !Array.isArray(entry) && Object.keys(entry).length === 1);","tryCatchPattern":null,"preventionTips":["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"],"tags":["settings","custom-fields","json","configuration","client"],"backgroundTag":"invalid-json-config","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}