diff --git a/app/api/entities.v2/model/Entity.ts b/app/api/entities.v2/model/Entity.ts index 7b7d1b35d0..6c69f77ac8 100644 --- a/app/api/entities.v2/model/Entity.ts +++ b/app/api/entities.v2/model/Entity.ts @@ -87,7 +87,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/specs/RequestEntityTranslation.spec.ts b/app/api/externalIntegrations.v2/automaticTranslation/specs/RequestEntityTranslation.spec.ts index eada1fafdd..2a4db0e1b4 100644 --- a/app/api/externalIntegrations.v2/automaticTranslation/specs/RequestEntityTranslation.spec.ts +++ b/app/api/externalIntegrations.v2/automaticTranslation/specs/RequestEntityTranslation.spec.ts @@ -21,6 +21,7 @@ const fixtures: DBFixture = { factory.template('template1', [ factory.property('text1'), factory.property('text2', 'markdown'), + factory.property('text3'), factory.property('empty_text'), ]), ], @@ -28,6 +29,7 @@ const fixtures: DBFixture = { ...factory.entityInMultipleLanguages(['en', 'es', 'pt'], 'entity1', 'template1', { text1: [{ value: 'original text1' }], text2: [{ value: 'markdown text' }], + text3: [], empty_text: [{ value: '' }], }), ], @@ -47,6 +49,7 @@ const fixtures: DBFixture = { properties: [ factory.idString('text1'), factory.idString('text2'), + factory.idString('text3'), factory.idString('empty_text'), ], commonProperties: [factory.commonPropertiesTitleId('template1')],