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:
+1
-1
@@ -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,
|
||||
|
||||
+1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user