From 8353a2c766f1fb00519b5e3fc8a80b762c1223c0 Mon Sep 17 00:00:00 2001 From: Sonarly Claude Code Date: Wed, 22 Apr 2026 11:59:17 +0000 Subject: [PATCH] Fix record title cell crash when field value is not a string (#19109) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../components/RecordTitleCellTextFieldDisplay.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/twenty-front/src/modules/object-record/record-title-cell/components/RecordTitleCellTextFieldDisplay.tsx b/packages/twenty-front/src/modules/object-record/record-title-cell/components/RecordTitleCellTextFieldDisplay.tsx index 22a2aba8448..08340b0ffe7 100644 --- a/packages/twenty-front/src/modules/object-record/record-title-cell/components/RecordTitleCellTextFieldDisplay.tsx +++ b/packages/twenty-front/src/modules/object-record/record-title-cell/components/RecordTitleCellTextFieldDisplay.tsx @@ -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();