Fix user friendly message for non available object name (#14210)

Fixes https://github.com/twentyhq/twenty/issues/13577.

When naming or renaming an object, we are already checking that the name
was available compared to other existing objects.
But we also need to check that the relation fields that will be created
or updated are available as well: we create relation fields on
Attachment, Note, Favorite, Task and TimelineActivites, that bear the
name of the object. Thus, it is not possible to create an object that
has the same name as one of the fields on Attachment, Note etc: name,
createdAt, ... are not valid names.
This commit is contained in:
Marie
2025-09-01 18:35:40 +02:00
committed by GitHub
parent 3f7f78eef8
commit 0d5fedfb0a
13 changed files with 208 additions and 67 deletions
@@ -9,7 +9,7 @@ import {
export const buildDefaultFieldsForCustomObject = (
workspaceId: string,
): Partial<FieldMetadataEntity>[] => [
): Array<Partial<FieldMetadataEntity> & { id: string }> => [
{
id: v4(),
standardId: BASE_OBJECT_STANDARD_FIELD_IDS.id,
@@ -31,6 +31,7 @@ export const objectMetadataGraphqlApiExceptionHandler = (error: Error) => {
case ObjectMetadataExceptionCode.INVALID_OBJECT_INPUT:
throw new UserInputError(error);
case ObjectMetadataExceptionCode.OBJECT_MUTATION_NOT_ALLOWED:
case ObjectMetadataExceptionCode.NAME_CONFLICT:
throw new ForbiddenError(error);
case ObjectMetadataExceptionCode.OBJECT_ALREADY_EXISTS:
throw new ConflictError(error);