diff --git a/app/api/entities.v2/model/Entity.ts b/app/api/entities.v2/model/Entity.ts index 30ac8bd1e1..98475c8236 100644 --- a/app/api/entities.v2/model/Entity.ts +++ b/app/api/entities.v2/model/Entity.ts @@ -82,7 +82,7 @@ export class Entity { if (property.type === 'text' || property.type === 'markdown') { const isTitleProperty = property instanceof CommonProperty && property.name === 'title'; if (isTitleProperty) return this.title; - return this.metadata[property.name]?.[0]?.value as string; + return (this.metadata[property.name]?.[0]?.value as string) || ''; } throw new Error('types other than string/markdown are not implemented yet'); diff --git a/app/api/externalIntegrations.v2/automaticTranslation/utils/specs/ATSolveVersionConflict.spec.ts b/app/api/externalIntegrations.v2/automaticTranslation/utils/specs/ATSolveVersionConflict.spec.ts index 3947124585..fedec8ce6c 100644 --- a/app/api/externalIntegrations.v2/automaticTranslation/utils/specs/ATSolveVersionConflict.spec.ts +++ b/app/api/externalIntegrations.v2/automaticTranslation/utils/specs/ATSolveVersionConflict.spec.ts @@ -100,5 +100,18 @@ describe('ATSolveVersionConflict', () => { }, }); }); + + it('should not fail if the props have no value', async () => { + const currentEntity = factory.entity('current entity', 'template', { prop1: [] }); + const newEntity = factory.entity('new entity', 'template', { + prop1: [], + prop2: [{ value: 'prop2' }], + }); + + await expect(ATSolveVersionConflict(currentEntity, newEntity)).resolves.toMatchObject({ + title: 'new entity', + metadata: { prop1: [], prop2: [{ value: 'prop2' }] }, + }); + }); }); });