Skip to content

The open alternative to Salesforce, designed for AI.

[flexible-schema] Add reserved keyword check on object creation (#5303)

Weiko154ae99ed312
diff --git a/packages/twenty-server/src/engine/metadata-modules/object-metadata/hooks/before-create-one-object.hook.ts b/packages/twenty-server/src/engine/metadata-modules/object-metadata/hooks/before-create-one-object.hook.ts
index 48f3ec23e18..ca82a61ec8a 100644
--- a/packages/twenty-server/src/engine/metadata-modules/object-metadata/hooks/before-create-one-object.hook.ts
+++ b/packages/twenty-server/src/engine/metadata-modules/object-metadata/hooks/before-create-one-object.hook.ts
@@ -12,12 +12,24 @@ import {
import { CreateObjectInput } from 'src/engine/metadata-modules/object-metadata/dtos/create-object.input';
const coreObjectNames = [
- 'featureFlag',
'appToken',
- 'workspace',
+ 'billingSubscription',
+ 'billingSubscriptionItem',
+ 'featureFlag',
'user',
+ 'userWorkspace',
+ 'workspace',
+];
+
+const reservedKeywords = [
+ ...coreObjectNames,
'event',
'field',
+ 'link',
+ 'currency',
+ 'fullName',
+ 'address',
+ 'links',
];
@Injectable()
@@ -35,8 +47,8 @@ export class BeforeCreateOneObject<T extends CreateObjectInput>
}
if (
- coreObjectNames.includes(instance.input.nameSingular) ||
- coreObjectNames.includes(instance.input.namePlural)
+ reservedKeywords.includes(instance.input.nameSingular) ||
+ reservedKeywords.includes(instance.input.namePlural)
) {
throw new ForbiddenException(
'You cannot create an object with this name.',