Files
twenty/packages
Sonarly Claude Code 87ca4aaedc fix: handle non-string field types in useSortedArray to prevent localeCompare crash
https://sonarly.com/issue/17943?type=bug

Sorting the relations table by the "App" column on settings object detail pages crashes because `isCustom` is a boolean but the table metadata declares it as a string, causing `localeCompare` to be called on a boolean value.

Fix: **Two-layer fix:**

1. **Root cause fix — 3 table metadata files:** Changed `fieldType` from `'string'` to `'number'` for the `isCustom` field in all 3 table metadata constants where it was incorrect:
   - `SettingsObjectRelationsTable.tsx` (the crash site from the Sentry error)
   - `SettingsAiAgentTableMetadata.ts` (same bug, not yet reported)
   - `SettingsSkillTableMetadata.ts` (same bug, not yet reported)

   The `isCustom` field is a `Boolean` in the GraphQL schema. Since `TableFieldMetadata.fieldType` only supports `'string' | 'number'`, `'number'` is correct for booleans — JavaScript boolean arithmetic (`true - false = 1`) sorts correctly in the number comparator path.

2. **Defensive fix — `useSortedArray.ts`:** Replaced the unsafe `(value as string)?.localeCompare()` pattern with `String(value ?? '').localeCompare()`. This ensures that even if a future field is incorrectly declared as `'string'` when it's not, the sort won't crash — it will coerce the value to a string first. The `?? ''` handles null/undefined values that would otherwise become `"null"` or `"undefined"`.
2026-03-24 14:53:16 +00:00
..
2026-03-17 11:43:17 +01:00
2026-03-23 16:56:15 +00:00