Compare commits

...
Author SHA1 Message Date
Sonarly Claude Code 8353a2c766 Fix record title cell crash when field value is not a string (#19109)
https://sonarly.com/issue/29800?type=bug

The record title cell crashes with `TypeError: a.trim is not a function` when a custom object's label identifier TEXT field contains a non-string value (e.g., number, boolean) in the record store.

Fix: Replaced `!isDefined(fieldValue) || fieldValue.trim() === ''` with `typeof fieldValue !== 'string' || fieldValue.trim() === ''` on the isEmpty check. The `isDefined()` guard only rejects null/undefined, so any defined non-string value (number, boolean, object) passed through and crashed on `.trim()`. The `typeof` check is a proper runtime type narrowing: if fieldValue is not a string, isEmpty is immediately true (rendering the "Untitled" placeholder), and `.trim()` is only ever called on actual strings. Removed the now-unused `isDefined` import from `twenty-shared/utils`. This is a single-line logic change plus import cleanup — no API, prop, or behavioral changes outside the crash path. Non-string field values now gracefully display the empty-state placeholder instead of throwing a TypeError.
2026-04-22 11:59:17 +00:00
@@ -7,7 +7,6 @@ import { useAtomFamilyStateValue } from '@/ui/utilities/state/jotai/hooks/useAto
import { styled } from '@linaria/react';
import { t } from '@lingui/core/macro';
import { useContext } from 'react';
import { isDefined } from 'twenty-shared/utils';
import { OverflowingTextWithTooltip } from 'twenty-ui/display';
import { themeCssVariables } from 'twenty-ui/theme-constants';
@@ -43,7 +42,7 @@ export const RecordTitleCellSingleTextDisplayMode = ({
const recordStore = useAtomFamilyStateValue(recordStoreFamilyState, recordId);
const fieldValue = recordStore?.[fieldDefinition.metadata.fieldName];
const isEmpty = !isDefined(fieldValue) || fieldValue.trim() === '';
const isEmpty = typeof fieldValue !== 'string' || fieldValue.trim() === '';
const { openRecordTitleCell } = useRecordTitleCell();