From 53b853f877c446f81d58d7b09b759e06dde63981 Mon Sep 17 00:00:00 2001 From: Marie <51697796+ijreilly@users.noreply.github.com> Date: Wed, 17 Sep 2025 16:58:17 +0200 Subject: [PATCH] [fix] Handle null icon for field metadata (#14565) Fixes https://github.com/twentyhq/twenty/issues/14548. When creating a field metadata through the api, the field's icon can be null (from twenty UI, a default icon is always added by default and it is not possible to remove it). Then this value is turned into an empty string in the payload - i don't know why we don't send the null value. When updating the field through the UI, we run a zod validation that either accepts a null value for Icon, or a value that starts with `"Icon".` In our case, the value for Icon was `""` (an empty string), which is not valid. Therefore the form was considered not valid until an icon was added. While the fix suggested works, we should probably sort out the `null` conversion to `""`, as it is prone to errors. --- .../validation-schemas/fieldMetadataItemSchema.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/twenty-front/src/modules/object-metadata/validation-schemas/fieldMetadataItemSchema.ts b/packages/twenty-front/src/modules/object-metadata/validation-schemas/fieldMetadataItemSchema.ts index 32959c7a77..674bf4ae7e 100644 --- a/packages/twenty-front/src/modules/object-metadata/validation-schemas/fieldMetadataItemSchema.ts +++ b/packages/twenty-front/src/modules/object-metadata/validation-schemas/fieldMetadataItemSchema.ts @@ -12,7 +12,10 @@ export const fieldMetadataItemSchema = (existingLabels?: string[]) => { createdAt: z.string().datetime(), defaultValue: z.any().optional(), description: z.string().trim().nullable().optional(), - icon: z.string().startsWith('Icon').trim().nullable(), + icon: z + .union([z.string().startsWith('Icon').trim(), z.literal('')]) + .nullable() + .optional(), id: z.string().uuid(), isActive: z.boolean(), isCustom: z.boolean(),