The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
feat(application): deprecate uploadApplicationFile and drop the CLI multipart fallback (#26379)
martmullad7244b079eb
diff --git a/packages/twenty-client-sdk/src/metadata/generated/schema.graphql b/packages/twenty-client-sdk/src/metadata/generated/schema.graphqlindex 562c13b362e..e63402e6d77 100644--- a/packages/twenty-client-sdk/src/metadata/generated/schema.graphql+++ b/packages/twenty-client-sdk/src/metadata/generated/schema.graphql@@ -4019,7 +4019,7 @@ type Mutation {uploadWorkspaceMemberProfilePicture(file: Upload!): FileWithSignedUrl! @deprecated(reason: "Use createFileUpload with the CorePicture folder and completeWorkspaceMemberProfilePictureUpload, which send the picture straight to file storage.")completeWorkspaceLogoUpload(fileId: String!): FileWithSignedUrl!completeWorkspaceMemberProfilePictureUpload(fileId: String!): FileWithSignedUrl!- uploadFilesFieldFileByUniversalIdentifier(file: Upload!, fieldMetadataUniversalIdentifier: String!): FileWithSignedUrl!+ uploadFilesFieldFileByUniversalIdentifier(file: Upload!, fieldMetadataUniversalIdentifier: String!): FileWithSignedUrl! @deprecated(reason: "Use createFileUpload with the FilesField folder and the fieldMetadataUniversalIdentifier, then completeFileUpload, which send the file straight to file storage.")createUsageLimit(input: CreateUsageLimitInput!): UsageLimit!updateUsageLimit(input: UpdateUsageLimitInput!): UsageLimit!deleteUsageLimit(usageLimitId: UUID!): Boolean!@@ -4262,7 +4262,7 @@ type Mutation {checkPublicDomainValidRecords(domain: String!): DomainValidRecordscreateDevelopmentApplication(universalIdentifier: String!, name: String!): DevelopmentApplication!syncApplication(manifest: JSON!, dryRun: Boolean, inferDeletionFromMissingEntities: Boolean): WorkspaceMigration!- uploadApplicationFile(file: Upload!, applicationUniversalIdentifier: String!, fileFolder: FileFolder!, filePath: String!): File!+ uploadApplicationFile(file: Upload!, applicationUniversalIdentifier: String!, fileFolder: FileFolder!, filePath: String!): File! @deprecated(reason: "Use createApplicationFileUploads and completeApplicationFileUploads, which send the files straight to file storage.")createApplicationFileUploads(applicationUniversalIdentifier: String!, files: [ApplicationFileUploadRequestInput!]!): CreateApplicationFileUploadsResult!completeApplicationFileUploads(applicationUniversalIdentifier: String!, fileIds: [UUID!]!): CompleteApplicationFileUploadsResult!revokeApplicationAuthorization(applicationAuthorizationId: UUID!): Boolean!diff --git a/packages/twenty-client-sdk/src/metadata/generated/schema.ts b/packages/twenty-client-sdk/src/metadata/generated/schema.tsindex 79d50db3fbb..5d40706f090 100644--- a/packages/twenty-client-sdk/src/metadata/generated/schema.ts+++ b/packages/twenty-client-sdk/src/metadata/generated/schema.ts@@ -3434,6 +3434,7 @@ export interface Mutation {uploadWorkspaceMemberProfilePicture: FileWithSignedUrlcompleteWorkspaceLogoUpload: FileWithSignedUrlcompleteWorkspaceMemberProfilePictureUpload: FileWithSignedUrl+ /** @deprecated Use createFileUpload with the FilesField folder and the fieldMetadataUniversalIdentifier, then completeFileUpload, which send the file straight to file storage. */uploadFilesFieldFileByUniversalIdentifier: FileWithSignedUrlcreateUsageLimit: UsageLimitupdateUsageLimit: UsageLimit@@ -3681,6 +3682,7 @@ export interface Mutation {checkPublicDomainValidRecords?: DomainValidRecordscreateDevelopmentApplication: DevelopmentApplicationsyncApplication: WorkspaceMigration+ /** @deprecated Use createApplicationFileUploads and completeApplicationFileUploads, which send the files straight to file storage. */uploadApplicationFile: FilecreateApplicationFileUploads: CreateApplicationFileUploadsResultcompleteApplicationFileUploads: CompleteApplicationFileUploadsResult@@ -7322,6 +7324,7 @@ export interface MutationGenqlSelection{uploadWorkspaceMemberProfilePicture?: (FileWithSignedUrlGenqlSelection & { __args: {file: Scalars['Upload']} })completeWorkspaceLogoUpload?: (FileWithSignedUrlGenqlSelection & { __args: {fileId: Scalars['String']} })completeWorkspaceMemberProfilePictureUpload?: (FileWithSignedUrlGenqlSelection & { __args: {fileId: Scalars['String']} })+ /** @deprecated Use createFileUpload with the FilesField folder and the fieldMetadataUniversalIdentifier, then completeFileUpload, which send the file straight to file storage. */uploadFilesFieldFileByUniversalIdentifier?: (FileWithSignedUrlGenqlSelection & { __args: {file: Scalars['Upload'], fieldMetadataUniversalIdentifier: Scalars['String']} })createUsageLimit?: (UsageLimitGenqlSelection & { __args: {input: CreateUsageLimitInput} })updateUsageLimit?: (UsageLimitGenqlSelection & { __args: {input: UpdateUsageLimitInput} })@@ -7569,6 +7572,7 @@ export interface MutationGenqlSelection{checkPublicDomainValidRecords?: (DomainValidRecordsGenqlSelection & { __args: {domain: Scalars['String']} })createDevelopmentApplication?: (DevelopmentApplicationGenqlSelection & { __args: {universalIdentifier: Scalars['String'], name: Scalars['String']} })syncApplication?: (WorkspaceMigrationGenqlSelection & { __args: {manifest: Scalars['JSON'], dryRun?: (Scalars['Boolean'] | null), inferDeletionFromMissingEntities?: (Scalars['Boolean'] | null)} })+ /** @deprecated Use createApplicationFileUploads and completeApplicationFileUploads, which send the files straight to file storage. */uploadApplicationFile?: (FileGenqlSelection & { __args: {file: Scalars['Upload'], applicationUniversalIdentifier: Scalars['String'], fileFolder: FileFolder, filePath: Scalars['String']} })createApplicationFileUploads?: (CreateApplicationFileUploadsResultGenqlSelection & { __args: {applicationUniversalIdentifier: Scalars['String'], files: ApplicationFileUploadRequestInput[]} })completeApplicationFileUploads?: (CompleteApplicationFileUploadsResultGenqlSelection & { __args: {applicationUniversalIdentifier: Scalars['String'], fileIds: Scalars['UUID'][]} })diff --git a/packages/twenty-front/src/generated-metadata/graphql.ts b/packages/twenty-front/src/generated-metadata/graphql.tsindex e16b63b72fb..4690beab4d0 100644--- a/packages/twenty-front/src/generated-metadata/graphql.ts+++ b/packages/twenty-front/src/generated-metadata/graphql.ts@@ -3274,7 +3274,9 @@ export type Mutation = {upgradeApplication: Scalars['Boolean']['output'];/** @deprecated Use createFileUpload with the AppTarball folder and completeAppTarballUpload, which send the tarball straight to file storage. */uploadAppTarball: ApplicationRegistration;+ /** @deprecated Use createApplicationFileUploads and completeApplicationFileUploads, which send the files straight to file storage. */uploadApplicationFile: File;+ /** @deprecated Use createFileUpload with the FilesField folder and the fieldMetadataUniversalIdentifier, then completeFileUpload, which send the file straight to file storage. */uploadFilesFieldFileByUniversalIdentifier: FileWithSignedUrl;/** @deprecated Use createNewWorkspaceLogoUpload and completeNewWorkspaceLogoUpload, which send the logo straight to file storage. */uploadNewWorkspaceLogo: FileWithSignedUrl;diff --git a/packages/twenty-sdk/CHANGELOG.md b/packages/twenty-sdk/CHANGELOG.mdindex af8fc1ab4f5..1194a8293a6 100644--- a/packages/twenty-sdk/CHANGELOG.md+++ b/packages/twenty-sdk/CHANGELOG.md@@ -26,6 +26,10 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), andThe returned `{ id, path, size, createdAt, url }` is unchanged. `uploadFile` now requires a Twenty server that exposes the `createFileUpload` and `completeFileUpload` mutations.+### Removed++- **The per-file multipart fallback in `twenty app deploy` and `twenty app dev`.** Application files are only uploaded straight to file storage now (`createApplicationFileUploads`, PUT, `completeApplicationFileUploads`). The CLI no longer falls back to the `uploadApplicationFile` mutation on a server that lacks the batch mutations, so deploying to a server older than the direct upload fails instead of degrading.+### Added- **`enqueueJobs` in `twenty-sdk/logic-function`.** Enqueues one run per payload of a single logic function in one call (up to 200 payloads per batch). `retryLimit` and `delayMs` apply to every run in the batch.diff --git a/packages/twenty-sdk/src/cli/utilities/api/api-service.ts b/packages/twenty-sdk/src/cli/utilities/api/api-service.tsindex eff5207fa33..47723c9af48 100644--- a/packages/twenty-sdk/src/cli/utilities/api/api-service.ts+++ b/packages/twenty-sdk/src/cli/utilities/api/api-service.ts@@ -129,10 +129,6 @@ export class ApiService {return this.fileApi.installTarballApp(...args);}- uploadFile(...args: Parameters<FileApi['uploadFile']>) {- return this.fileApi.uploadFile(...args);- }-createApplicationFileUploads(...args: Parameters<FileApi['createApplicationFileUploads']>) {diff --git a/packages/twenty-sdk/src/cli/utilities/api/file-api.ts b/packages/twenty-sdk/src/cli/utilities/api/file-api.tsindex 7589ac9d491..286a52bd52e 100644--- a/packages/twenty-sdk/src/cli/utilities/api/file-api.ts+++ b/packages/twenty-sdk/src/cli/utilities/api/file-api.ts@@ -1,55 +1,10 @@import { type ApiResponse } from '@/cli/utilities/api/api-response-type';import { serializeError } from '@/cli/utilities/error/serialize-error';import axios, { type AxiosInstance, type AxiosResponse } from 'axios';-import * as fs from 'fs';-import * as path from 'path';import { type MetadataValidationErrorResponse } from 'twenty-shared/metadata';import { type FileFolder } from 'twenty-shared/types';import { pascalCase } from 'twenty-shared/utils';-const MIME_TYPES: Record<string, string> = {- '.jpg': 'image/jpeg',- '.jpeg': 'image/jpeg',- '.png': 'image/png',- '.gif': 'image/gif',- '.webp': 'image/webp',- '.svg': 'image/svg+xml',- '.bmp': 'image/bmp',- '.ico': 'image/x-icon',- '.pdf': 'application/pdf',- '.doc': 'application/msword',- '.docx':- 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',- '.xls': 'application/vnd.ms-excel',- '.xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',- '.ppt': 'application/vnd.ms-powerpoint',- '.pptx':- 'application/vnd.openxmlformats-officedocument.presentationml.presentation',- '.txt': 'text/plain',- '.csv': 'text/csv',- '.json': 'application/json',- '.xml': 'application/xml',- '.zip': 'application/zip',- '.tar': 'application/x-tar',- '.gz': 'application/gzip',- '.mp3': 'audio/mpeg',- '.mp4': 'video/mp4',- '.avi': 'video/x-msvideo',- '.mov': 'video/quicktime',- '.js': 'application/javascript',- '.ts': 'application/typescript',- '.jsx': 'application/javascript',- '.tsx': 'application/typescript',- '.html': 'text/html',- '.css': 'text/css',-};--const getMimeType = (filename: string): string => {- const ext = path.extname(filename).toLowerCase();-- return MIME_TYPES[ext] || 'application/octet-stream';-};-export type ApplicationFileUploadRequest = {fileFolder: FileFolder;filePath: string;@@ -209,96 +164,6 @@ export class FileApi {}}- async uploadFile({- filePath,- builtHandlerPath,- fileFolder,- applicationUniversalIdentifier,- }: {- filePath: string;- builtHandlerPath: string;- fileFolder: FileFolder;- applicationUniversalIdentifier: string;- }): Promise<ApiResponse<boolean>> {- try {- const absolutePath = path.resolve(filePath);-- if (!fs.existsSync(absolutePath)) {- return {- success: false,- error: `File not found: ${absolutePath}`,- };- }-- const filename = path.basename(absolutePath);- const buffer = fs.readFileSync(absolutePath);- const mimeType = getMimeType(filename);-- const mutation = `- mutation UploadApplicationFile($file: Upload!, $applicationUniversalIdentifier: String!, $fileFolder: FileFolder!, $filePath: String!) {- uploadApplicationFile(file: $file, applicationUniversalIdentifier: $applicationUniversalIdentifier, fileFolder: $fileFolder, filePath: $filePath)- { path }- }- `;-- const graphqlEnumFileFolder = pascalCase(fileFolder);-- const operations = JSON.stringify({- query: mutation,- variables: {- file: null,- applicationUniversalIdentifier,- filePath: builtHandlerPath,- fileFolder: graphqlEnumFileFolder,- },- });-- const map = JSON.stringify({- '0': ['variables.file'],- });-- const formData = new FormData();-- formData.append('operations', operations);- formData.append('map', map);- formData.append(- '0',- new Blob([new Uint8Array(buffer)], { type: mimeType }),- filename,- );-- const response: AxiosResponse = await this.client.post(- '/metadata',- formData,- );-- if (response.data.errors) {- return {- success: false,- error: response.data.errors[0]?.message || 'Failed to upload file',- };- }-- return {- success: true,- data: response.data.data.uploadApplicationFile,- message: `Successfully uploaded ${filename}`,- };- } catch (error) {- if (axios.isAxiosError(error) && error.response) {- return {- success: false,- error: error.response.data?.errors?.[0]?.message || error.message,- };- }-- return {- success: false,- error,- };- }- }-async createApplicationFileUploads({applicationUniversalIdentifier,files,diff --git a/packages/twenty-sdk/src/cli/utilities/api/is-missing-graphql-field-error.ts b/packages/twenty-sdk/src/cli/utilities/api/is-missing-graphql-field-error.tsdeleted file mode 100644index fe958476a89..00000000000--- a/packages/twenty-sdk/src/cli/utilities/api/is-missing-graphql-field-error.ts+++ /dev/null@@ -1,18 +0,0 @@-import { serializeError } from '@/cli/utilities/error/serialize-error';--export const isMissingGraphqlFieldError = ({- error,- fieldNames,-}: {- error: unknown;- fieldNames: string[];-}): boolean => {- const message = serializeError(error);-- return (- fieldNames.some((fieldName) => message.includes(fieldName)) &&- (message.includes('Cannot query field') ||- message.includes('Unknown type') ||- message.includes('Unknown field'))- );-};diff --git a/packages/twenty-sdk/src/cli/utilities/file/__tests__/file-uploader.spec.ts b/packages/twenty-sdk/src/cli/utilities/file/__tests__/file-uploader.spec.tsindex 5d4e88f4e41..23aac061951 100644--- a/packages/twenty-sdk/src/cli/utilities/file/__tests__/file-uploader.spec.ts+++ b/packages/twenty-sdk/src/cli/utilities/file/__tests__/file-uploader.spec.ts@@ -8,14 +8,12 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';const mockCreateApplicationFileUploads = vi.fn();const mockCompleteApplicationFileUploads = vi.fn();-const mockUploadFile = vi.fn();const mockPutFileToUploadUrl = vi.fn();vi.mock('@/cli/utilities/api/api-service', () => ({ApiService: class {createApplicationFileUploads = mockCreateApplicationFileUploads;completeApplicationFileUploads = mockCompleteApplicationFileUploads;- uploadFile = mockUploadFile;},}));@@ -68,7 +66,6 @@ describe('FileUploader.uploadFiles', () => {success: true,data: { files: [], errors: [] },});- mockUploadFile.mockResolvedValue({ success: true, data: true });mockPutFileToUploadUrl.mockResolvedValue(undefined);});@@ -132,62 +129,6 @@ describe('FileUploader.uploadFiles', () => {expect(mockCompleteApplicationFileUploads).not.toHaveBeenCalled();});- it('should fall back to multipart uploads when the server does not support direct uploads', async () => {- mockCreateApplicationFileUploads.mockResolvedValue({- success: false,- error:- 'Cannot query field "createApplicationFileUploads" on type "Mutation".',- });-- const failures = await buildUploader().uploadFiles(filesToUpload);-- expect(failures).toEqual([]);- expect(mockUploadFile).toHaveBeenCalledTimes(2);- expect(mockUploadFile).toHaveBeenCalledWith({- applicationUniversalIdentifier: 'application-uid',- builtHandlerPath: 'handler.mjs',- fileFolder: FileFolder.BuiltLogicFunction,- filePath: join(appPath, OUTPUT_DIR, 'handler.mjs'),- });- expect(mockPutFileToUploadUrl).not.toHaveBeenCalled();- expect(mockCompleteApplicationFileUploads).not.toHaveBeenCalled();- });-- it('should report multipart upload failures after falling back for an older server', async () => {- mockCreateApplicationFileUploads.mockResolvedValue({- success: false,- error:- 'Cannot query field "createApplicationFileUploads" on type "Mutation".',- });- mockUploadFile.mockResolvedValueOnce({- success: false,- error: 'legacy upload failed',- });-- const failures = await buildUploader().uploadFiles(filesToUpload);-- expect(failures).toEqual([- {- builtPath: join(OUTPUT_DIR, 'handler.mjs'),- error: 'legacy upload failed',- },- ]);- });-- it('should fall back when an older server rejects the direct upload input type', async () => {- mockCreateApplicationFileUploads.mockResolvedValue({- success: false,- error: 'Unknown type "ApplicationFileUploadRequestInput".',- });-- const failures = await buildUploader().uploadFiles(filesToUpload);-- expect(failures).toEqual([]);- expect(mockUploadFile).toHaveBeenCalledTimes(2);- expect(mockPutFileToUploadUrl).not.toHaveBeenCalled();- expect(mockCompleteApplicationFileUploads).not.toHaveBeenCalled();- });-it('should fail every uploaded file when the batch cannot be confirmed', async () => {mockCompleteApplicationFileUploads.mockResolvedValue({success: false,diff --git a/packages/twenty-sdk/src/cli/utilities/file/file-uploader.ts b/packages/twenty-sdk/src/cli/utilities/file/file-uploader.tsindex d94f6107917..8a9df7b1400 100644--- a/packages/twenty-sdk/src/cli/utilities/file/file-uploader.ts+++ b/packages/twenty-sdk/src/cli/utilities/file/file-uploader.ts@@ -1,6 +1,5 @@import { ApiService } from '@/cli/utilities/api/api-service';import { type ApplicationFileUploadRequest } from '@/cli/utilities/api/file-api';-import { isMissingGraphqlFieldError } from '@/cli/utilities/api/is-missing-graphql-field-error';import { serializeError } from '@/cli/utilities/error/serialize-error';import { putFileToUploadUrl } from '@/cli/utilities/file/put-file-to-upload-url';import * as fs from 'fs';@@ -80,19 +79,6 @@ export class FileUploader {});if (!createResult.success) {- if (- isMissingGraphqlFieldError({- error: createResult.error ?? createResult.message,- fieldNames: [- 'createApplicationFileUploads',- 'ApplicationFileUploadRequestInput',- 'CreateApplicationFileUploads',- ],- })- ) {- return this.uploadBatchWithMultipartMutation(batch);- }-return this.failWholeBatch(batch, serializeError(createResult.error));}@@ -159,30 +145,6 @@ export class FileUploader {return failures;}- private async uploadBatchWithMultipartMutation(- batch: FileToUpload[],- ): Promise<FileUploadFailure[]> {- const failures: FileUploadFailure[] = [];-- await this.runWithConcurrency(batch, async ({ builtPath, fileFolder }) => {- const result = await this.apiService.uploadFile({- filePath: path.join(this.appPath, builtPath),- builtHandlerPath: relative(OUTPUT_DIR, builtPath),- fileFolder,- applicationUniversalIdentifier: this.applicationUniversalIdentifier,- });-- if (!result.success) {- failures.push({- builtPath,- error: serializeError(result.error ?? result.message),- });- }- });-- return failures;- }-private failWholeBatch(batch: FileToUpload[],error: string,diff --git a/packages/twenty-server/src/engine/constants/settings/index.ts b/packages/twenty-server/src/engine/constants/settings/index.tsindex 57ee071b0a1..38701b4e090 100644--- a/packages/twenty-server/src/engine/constants/settings/index.ts+++ b/packages/twenty-server/src/engine/constants/settings/index.ts@@ -2,13 +2,14 @@ import { type Settings } from './interfaces/settings.interface';export const settings: Settings = {storage: {- maxFileSize: '100MB',+ maxMultipartFileSize: '5MB',// Direct uploads (createFileUpload/completeFileUpload) stream to storage// without transiting the server memory, so they get a much higher cap// than multipart uploads.maxDirectUploadFileSize: '1GB',maxCorePictureFileSize: '10MB',},+ maxRequestBodySize: '100MB',minLengthOfStringForDuplicateCheck: 3,maxVisibleViewFields: 30,};diff --git a/packages/twenty-server/src/engine/constants/settings/interfaces/settings.interface.ts b/packages/twenty-server/src/engine/constants/settings/interfaces/settings.interface.tsindex 18b123b5505..2adedcd284d 100644--- a/packages/twenty-server/src/engine/constants/settings/interfaces/settings.interface.ts+++ b/packages/twenty-server/src/engine/constants/settings/interfaces/settings.interface.ts@@ -1,9 +1,10 @@export interface Settings {storage: {- maxFileSize: `${number}MB`;+ maxMultipartFileSize: `${number}MB`;maxDirectUploadFileSize: `${number}MB` | `${number}GB`;maxCorePictureFileSize: `${number}MB`;};+ maxRequestBodySize: `${number}MB`;minLengthOfStringForDuplicateCheck: number;maxVisibleViewFields: number;}diff --git a/packages/twenty-server/src/engine/core-modules/application/application-development/application-development.resolver.ts b/packages/twenty-server/src/engine/core-modules/application/application-development/application-development.resolver.tsindex ae9fb9ace84..19f52f7ea55 100644--- a/packages/twenty-server/src/engine/core-modules/application/application-development/application-development.resolver.ts+++ b/packages/twenty-server/src/engine/core-modules/application/application-development/application-development.resolver.ts@@ -89,7 +89,10 @@ export class ApplicationDevelopmentResolver {});}- @Mutation(() => FileDTO)+ @Mutation(() => FileDTO, {+ deprecationReason:+ 'Use createApplicationFileUploads and completeApplicationFileUploads, which send the files straight to file storage.',+ })@UseGuards(SettingsPermissionGuard(PermissionFlagType.UPLOAD_FILE))async uploadApplicationFile(@AuthWorkspace() { id: workspaceId }: WorkspaceEntity,@@ -110,7 +113,7 @@ export class ApplicationDevelopmentResolver {getFileBuffer: () =>streamToBuffer(createReadStream(),- bytes(settings.storage.maxFileSize) ?? undefined,+ bytes(settings.storage.maxMultipartFileSize) ?? undefined,),});}diff --git a/packages/twenty-server/src/engine/core-modules/auth/auth.resolver.ts b/packages/twenty-server/src/engine/core-modules/auth/auth.resolver.tsindex 2e2ba01d7af..0894bc8ce57 100644--- a/packages/twenty-server/src/engine/core-modules/auth/auth.resolver.ts+++ b/packages/twenty-server/src/engine/core-modules/auth/auth.resolver.ts@@ -671,7 +671,7 @@ export class AuthResolver {const buffer = await streamToBuffer(createReadStream(),- bytes(settings.storage.maxFileSize) ?? undefined,+ bytes(settings.storage.maxMultipartFileSize) ?? undefined,);return this.fileCorePictureService.uploadWorkspacePicture({diff --git a/packages/twenty-server/src/engine/core-modules/file/file-core-picture/resolvers/file-core-picture.resolver.ts b/packages/twenty-server/src/engine/core-modules/file/file-core-picture/resolvers/file-core-picture.resolver.tsindex 4756db1d12b..c6360117cc2 100644--- a/packages/twenty-server/src/engine/core-modules/file/file-core-picture/resolvers/file-core-picture.resolver.ts+++ b/packages/twenty-server/src/engine/core-modules/file/file-core-picture/resolvers/file-core-picture.resolver.ts@@ -54,7 +54,7 @@ export class FileCorePictureResolver {): Promise<FileWithSignedUrlDTO> {const buffer = await streamToBuffer(createReadStream(),- bytes(settings.storage.maxFileSize) ?? undefined,+ bytes(settings.storage.maxMultipartFileSize) ?? undefined,);return await this.fileCorePictureService.uploadWorkspacePicture({@@ -76,7 +76,7 @@ export class FileCorePictureResolver {): Promise<FileWithSignedUrlDTO> {const buffer = await streamToBuffer(createReadStream(),- bytes(settings.storage.maxFileSize) ?? undefined,+ bytes(settings.storage.maxMultipartFileSize) ?? undefined,);return await this.fileCorePictureService.uploadWorkspaceMemberProfilePicture(diff --git a/packages/twenty-server/src/engine/core-modules/file/files-field/resolvers/files-field.resolver.ts b/packages/twenty-server/src/engine/core-modules/file/files-field/resolvers/files-field.resolver.tsindex ab931642ab2..89859003305 100644--- a/packages/twenty-server/src/engine/core-modules/file/files-field/resolvers/files-field.resolver.ts+++ b/packages/twenty-server/src/engine/core-modules/file/files-field/resolvers/files-field.resolver.ts@@ -32,7 +32,10 @@ import { UsageLimitGraphqlApiExceptionFilter } from 'src/engine/core-modules/usaexport class FilesFieldResolver {constructor(private readonly filesFieldService: FilesFieldService) {}- @Mutation(() => FileWithSignedUrlDTO)+ @Mutation(() => FileWithSignedUrlDTO, {+ deprecationReason:+ 'Use createFileUpload with the FilesField folder and the fieldMetadataUniversalIdentifier, then completeFileUpload, which send the file straight to file storage.',+ })@UseGuards(SettingsPermissionGuard(PermissionFlagType.UPLOAD_FILE))async uploadFilesFieldFileByUniversalIdentifier(@AuthWorkspace()@@ -49,7 +52,7 @@ export class FilesFieldResolver {const stream = createReadStream();const buffer = await streamToBuffer(stream,- bytes(settings.storage.maxFileSize) ?? undefined,+ bytes(settings.storage.maxMultipartFileSize) ?? undefined,);return await this.filesFieldService.uploadFile({diff --git a/packages/twenty-server/src/main.ts b/packages/twenty-server/src/main.tsindex 039b5424b73..39e6822455a 100644--- a/packages/twenty-server/src/main.ts+++ b/packages/twenty-server/src/main.ts@@ -76,9 +76,9 @@ const bootstrap = async () => {app.useLogger(logger);- app.useBodyParser('json', { limit: settings.storage.maxFileSize });+ app.useBodyParser('json', { limit: settings.maxRequestBodySize });app.useBodyParser('urlencoded', {- limit: settings.storage.maxFileSize,+ limit: settings.maxRequestBodySize,extended: true,});app.useBodyParser('text', { type: 'text/plain', limit: '1024kb' });@@ -86,8 +86,8 @@ const bootstrap = async () => {app.use(`/${ApiPath.GraphQL}`,graphqlUploadExpress({- maxFieldSize: bytes(settings.storage.maxFileSize)!,- maxFileSize: bytes(settings.storage.maxFileSize)!,+ maxFieldSize: bytes(settings.maxRequestBodySize)!,+ maxFileSize: bytes(settings.maxRequestBodySize)!,maxFiles: 10,}),);@@ -95,8 +95,8 @@ const bootstrap = async () => {app.use(`/${ApiPath.Metadata}`,graphqlUploadExpress({- maxFieldSize: bytes(settings.storage.maxFileSize)!,- maxFileSize: bytes(settings.storage.maxFileSize)!,+ maxFieldSize: bytes(settings.maxRequestBodySize)!,+ maxFileSize: bytes(settings.maxRequestBodySize)!,maxFiles: 10,}),);diff --git a/packages/twenty-server/test/integration/metadata/suites/application/__snapshots__/failing-direct-application-file-upload-mime-mismatch.integration-spec.ts.snap b/packages/twenty-server/test/integration/metadata/suites/application/__snapshots__/failing-direct-application-file-upload-mime-mismatch.integration-spec.ts.snapnew file mode 100644index 00000000000..0f03093a1b8--- /dev/null+++ b/packages/twenty-server/test/integration/metadata/suites/application/__snapshots__/failing-direct-application-file-upload-mime-mismatch.integration-spec.ts.snap@@ -0,0 +1,7 @@+// Jest Snapshot v1, https://goo.gl/fbAQLP++exports[`Application file upload should fail at completion on mime/magic-byte mismatch when a PublicAsset .pdf path receives a plain text body (magic-byte mismatch) 1`] = `"File content does not match its extension. The file has extension 'pdf' (expected mime type: application/pdf), but the file content could not be detected as this type. The file may be corrupted, have the wrong extension, or be a security risk."`;++exports[`Application file upload should fail at completion on mime/magic-byte mismatch when a PublicAsset .png path receives a plain text body (magic-byte mismatch) 1`] = `"File content does not match its extension. The file has extension 'png' (expected mime type: image/png), but the file content could not be detected as this type. The file may be corrupted, have the wrong extension, or be a security risk."`;++exports[`Application file upload should fail at completion on mime/magic-byte mismatch when a PublicAsset .zip path receives a plain text body (magic-byte mismatch) 1`] = `"File content does not match its extension. The file has extension 'zip' (expected mime type: application/zip), but the file content could not be detected as this type. The file may be corrupted, have the wrong extension, or be a security risk."`;diff --git a/packages/twenty-server/test/integration/metadata/suites/application/__snapshots__/failing-direct-application-file-upload-path-traversal.integration-spec.ts.snap b/packages/twenty-server/test/integration/metadata/suites/application/__snapshots__/failing-direct-application-file-upload-path-traversal.integration-spec.ts.snapnew file mode 100644index 00000000000..896df59f875--- /dev/null+++ b/packages/twenty-server/test/integration/metadata/suites/application/__snapshots__/failing-direct-application-file-upload-path-traversal.integration-spec.ts.snap@@ -0,0 +1,48 @@+// Jest Snapshot v1, https://goo.gl/fbAQLP++exports[`Application file upload reservation should fail when applicationUniversalIdentifier does not match any installed application 1`] = `+{+ "extensions": {+ "code": "NOT_FOUND",+ "subCode": "APPLICATION_NOT_FOUND",+ "userFriendlyMessage": "Application not found.",+ },+ "message": "Application not found in workspace.",+ "name": "NotFoundError",+}+`;++exports[`Application file upload reservation should fail when applicationUniversalIdentifier is empty 1`] = `+{+ "extensions": {+ "code": "BAD_USER_INPUT",+ "userFriendlyMessage": "An error occurred.",+ },+ "message": "applicationUniversalIdentifier should not be empty",+ "name": "UserInputError",+}+`;++exports[`Application file upload reservation should fail when fileFolder is not an allowed application file folder 1`] = `"Invalid fileFolder for application file upload. Allowed values: built-logic-function, built-front-component, public-asset, source, dependencies"`;++exports[`Application file upload reservation should fail when filePath contains backslash path traversal 1`] = `"Resource path must not contain backslashes"`;++exports[`Application file upload reservation should fail when filePath contains relative path traversal (../) 1`] = `"Resource path must not contain path traversal (..)"`;++exports[`Application file upload reservation should fail when filePath contains upward traversal (../../) 1`] = `"Resource path must not contain path traversal (..)"`;++exports[`Application file upload reservation should fail when filePath has an invalid extension for BuiltFrontComponent (.js instead of .mjs) 1`] = `"Invalid file extension. Allowed extensions: .mjs"`;++exports[`Application file upload reservation should fail when filePath has an invalid extension for BuiltLogicFunction (.html) 1`] = `"Invalid file extension. Allowed extensions: .mjs"`;++exports[`Application file upload reservation should fail when filePath has an invalid extension for Dependencies (.sh instead of .json/.lock) 1`] = `"Invalid file extension. Allowed extensions: .json, .lock"`;++exports[`Application file upload reservation should fail when filePath has an invalid extension for Source (.js instead of .ts) 1`] = `"Invalid file extension. Allowed extensions: .ts, .tsx, .json"`;++exports[`Application file upload reservation should fail when filePath is a folder path without extension (bare UUID) 1`] = `"Filename must have an extension"`;++exports[`Application file upload reservation should fail when filePath is a nested folder path without extension 1`] = `"Filename must have an extension"`;++exports[`Application file upload reservation should fail when filePath is an absolute path 1`] = `"Resource path must be relative, not absolute"`;++exports[`Application file upload reservation should fail when filePath is empty 1`] = `"Resource path must not be empty"`;diff --git a/packages/twenty-server/test/integration/metadata/suites/application/failing-direct-application-file-upload-mime-mismatch.integration-spec.ts b/packages/twenty-server/test/integration/metadata/suites/application/failing-direct-application-file-upload-mime-mismatch.integration-spec.tsnew file mode 100644index 00000000000..d6f825ec67d--- /dev/null+++ b/packages/twenty-server/test/integration/metadata/suites/application/failing-direct-application-file-upload-mime-mismatch.integration-spec.ts@@ -0,0 +1,152 @@+import { cleanupApplicationAndAppRegistration } from 'test/integration/metadata/suites/application/utils/cleanup-application-and-app-registration.util';+import { completeApplicationFileUploads } from 'test/integration/metadata/suites/application/utils/complete-application-file-uploads.util';+import { createApplicationFileUploads } from 'test/integration/metadata/suites/application/utils/create-application-file-uploads.util';+import { putApplicationFileUploadTarget } from 'test/integration/metadata/suites/application/utils/put-application-file-upload-target.util';+import { setupApplicationForSync } from 'test/integration/metadata/suites/application/utils/setup-application-for-sync.util';+import { uploadApplicationFileWithDirectUpload } from 'test/integration/metadata/suites/application/utils/upload-application-file-with-direct-upload.util';+import {+ type EachTestingContext,+ eachTestingContextFilter,+} from 'twenty-shared/testing';+import { v4 as uuidv4 } from 'uuid';++const TEST_APP_ID = uuidv4();++const PNG_BUFFER = Buffer.from([+ 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49,+ 0x48, 0x44, 0x52,+]);+const TEXT_BUFFER = Buffer.from('not actually binary content', 'utf-8');++type TestContext = {+ fileFolder: string;+ filePath: string;+};++const FAILING_TEST_CASES: EachTestingContext<TestContext>[] = [+ {+ title:+ 'when a PublicAsset .png path receives a plain text body (magic-byte mismatch)',+ context: {+ fileFolder: 'PublicAsset',+ filePath: 'assets/fake-image.png',+ },+ },+ {+ title:+ 'when a PublicAsset .pdf path receives a plain text body (magic-byte mismatch)',+ context: {+ fileFolder: 'PublicAsset',+ filePath: 'docs/fake.pdf',+ },+ },+ {+ title:+ 'when a PublicAsset .zip path receives a plain text body (magic-byte mismatch)',+ context: {+ fileFolder: 'PublicAsset',+ filePath: 'archives/fake.zip',+ },+ },+];++describe('Application file upload should fail at completion on mime/magic-byte mismatch', () => {+ beforeAll(async () => {+ await setupApplicationForSync({+ applicationUniversalIdentifier: TEST_APP_ID,+ name: 'Test Upload Mime Mismatch App',+ description: 'App for testing magic-byte vs extension validation',+ sourcePath: 'test-upload-mime-mismatch',+ });+ }, 60000);++ afterAll(async () => {+ await cleanupApplicationAndAppRegistration({+ applicationUniversalIdentifier: TEST_APP_ID,+ });+ });++ it.each(eachTestingContextFilter(FAILING_TEST_CASES))(+ '$title',+ async ({ context }) => {+ jest.useRealTimers();++ const { data: createData, errors: createErrors } =+ await createApplicationFileUploads({+ applicationUniversalIdentifier: TEST_APP_ID,+ files: [+ {+ fileFolder: context.fileFolder,+ filePath: context.filePath,+ size: TEXT_BUFFER.length,+ },+ ],+ });++ expect(createErrors).toBeUndefined();++ const [uploadTarget] = createData.createApplicationFileUploads.targets;++ const putResponse = await putApplicationFileUploadTarget({+ uploadTarget,+ body: TEXT_BUFFER,+ });++ expect(putResponse.status).toBe(204);++ const { data: completeData, errors: completeErrors } =+ await completeApplicationFileUploads({+ applicationUniversalIdentifier: TEST_APP_ID,+ fileIds: [uploadTarget.fileId],+ });++ jest.useFakeTimers();++ expect(completeErrors).toBeUndefined();++ const { files, errors } = completeData.completeApplicationFileUploads;++ expect(files).toEqual([]);+ expect(errors).toHaveLength(1);+ expect(errors[0].fileId).toBe(uploadTarget.fileId);+ expect(errors[0].message).toMatchSnapshot();++ const [row] = await globalThis.testDataSource.query(+ `SELECT status FROM core."file" WHERE id = $1`,+ [uploadTarget.fileId],+ );++ expect(row.status).toBe('PENDING');+ },+ 60000,+ );++ it('should persist the mime type detected from the bytes', async () => {+ jest.useRealTimers();++ const filePath = 'assets/legit-image.png';++ const { data, errors } = await uploadApplicationFileWithDirectUpload({+ applicationUniversalIdentifier: TEST_APP_ID,+ fileFolder: 'PublicAsset',+ filePath,+ fileBuffer: PNG_BUFFER,+ expectToFail: false,+ });++ jest.useFakeTimers();++ expect(errors).toBeUndefined();+ expect(data?.uploadApplicationFile).toEqual({+ id: expect.any(String),+ path: `public-asset/${filePath}`,+ });++ const [row] = await globalThis.testDataSource.query(+ `SELECT "mimeType" FROM core."file" WHERE id = $1`,+ [data?.uploadApplicationFile.id],+ );++ expect(row.mimeType).toBe('image/png');+ }, 60000);+});diff --git a/packages/twenty-server/test/integration/metadata/suites/application/failing-direct-application-file-upload-path-traversal.integration-spec.ts b/packages/twenty-server/test/integration/metadata/suites/application/failing-direct-application-file-upload-path-traversal.integration-spec.tsnew file mode 100644index 00000000000..75d6db005e8--- /dev/null+++ b/packages/twenty-server/test/integration/metadata/suites/application/failing-direct-application-file-upload-path-traversal.integration-spec.ts@@ -0,0 +1,216 @@+import { expectOneNotInternalServerErrorSnapshot } from 'test/integration/graphql/utils/expect-one-not-internal-server-error-snapshot.util';+import { cleanupApplicationAndAppRegistration } from 'test/integration/metadata/suites/application/utils/cleanup-application-and-app-registration.util';+import { createApplicationFileUploads } from 'test/integration/metadata/suites/application/utils/create-application-file-uploads.util';+import { setupApplicationForSync } from 'test/integration/metadata/suites/application/utils/setup-application-for-sync.util';+import {+ type EachTestingContext,+ eachTestingContextFilter,+} from 'twenty-shared/testing';+import { v4 as uuidv4 } from 'uuid';++const TEST_APP_ID = uuidv4();+const UNKNOWN_APP_ID = uuidv4();++type FailureLevel = 'request' | 'file';++type TestContext = {+ applicationUniversalIdentifier: string;+ fileFolder: string;+ filePath: string;+ failureLevel: FailureLevel;+};++const FAILING_TEST_CASES: EachTestingContext<TestContext>[] = [+ {+ title: 'when filePath contains relative path traversal (../)',+ context: {+ applicationUniversalIdentifier: TEST_APP_ID,+ fileFolder: 'BuiltFrontComponent',+ filePath:+ '../../../other-workspace/other-app/BuiltFrontComponent/stolen.mjs',+ failureLevel: 'file',+ },+ },+ {+ title: 'when filePath contains upward traversal (../../)',+ context: {+ applicationUniversalIdentifier: TEST_APP_ID,+ fileFolder: 'BuiltFrontComponent',+ filePath: '../../etc/passwd',+ failureLevel: 'file',+ },+ },+ {+ title: 'when filePath is an absolute path',+ context: {+ applicationUniversalIdentifier: TEST_APP_ID,+ fileFolder: 'BuiltFrontComponent',+ filePath: '/etc/passwd',+ failureLevel: 'file',+ },+ },+ {+ title: 'when filePath contains backslash path traversal',+ context: {+ applicationUniversalIdentifier: TEST_APP_ID,+ fileFolder: 'BuiltFrontComponent',+ filePath: '..\\..\\..\\etc\\passwd',+ failureLevel: 'file',+ },+ },+ {+ title: 'when filePath is empty',+ context: {+ applicationUniversalIdentifier: TEST_APP_ID,+ fileFolder: 'BuiltFrontComponent',+ filePath: '',+ failureLevel: 'file',+ },+ },+ {+ title:+ 'when applicationUniversalIdentifier does not match any installed application',+ context: {+ applicationUniversalIdentifier: UNKNOWN_APP_ID,+ fileFolder: 'BuiltFrontComponent',+ filePath: 'src/components/legit.mjs',+ failureLevel: 'request',+ },+ },+ {+ title: 'when applicationUniversalIdentifier is empty',+ context: {+ applicationUniversalIdentifier: '',+ fileFolder: 'BuiltFrontComponent',+ filePath: 'src/components/legit.mjs',+ failureLevel: 'request',+ },+ },+ {+ title: 'when fileFolder is not an allowed application file folder',+ context: {+ applicationUniversalIdentifier: TEST_APP_ID,+ fileFolder: 'CorePicture',+ filePath: 'src/components/legit.mjs',+ failureLevel: 'file',+ },+ },+ {+ title: 'when filePath is a folder path without extension (bare UUID)',+ context: {+ applicationUniversalIdentifier: TEST_APP_ID,+ fileFolder: 'BuiltFrontComponent',+ filePath: '8b2df3cc-23ad-4e1b-87fd-f880d4cefd58',+ failureLevel: 'file',+ },+ },+ {+ title: 'when filePath is a nested folder path without extension',+ context: {+ applicationUniversalIdentifier: TEST_APP_ID,+ fileFolder: 'Source',+ filePath: 'src/logic-functions/my-handler',+ failureLevel: 'file',+ },+ },+ {+ title:+ 'when filePath has an invalid extension for BuiltFrontComponent (.js instead of .mjs)',+ context: {+ applicationUniversalIdentifier: TEST_APP_ID,+ fileFolder: 'BuiltFrontComponent',+ filePath: 'src/components/component.js',+ failureLevel: 'file',+ },+ },+ {+ title:+ 'when filePath has an invalid extension for BuiltLogicFunction (.html)',+ context: {+ applicationUniversalIdentifier: TEST_APP_ID,+ fileFolder: 'BuiltLogicFunction',+ filePath: 'src/handlers/handler.html',+ failureLevel: 'file',+ },+ },+ {+ title:+ 'when filePath has an invalid extension for Source (.js instead of .ts)',+ context: {+ applicationUniversalIdentifier: TEST_APP_ID,+ fileFolder: 'Source',+ filePath: 'src/index.js',+ failureLevel: 'file',+ },+ },+ {+ title:+ 'when filePath has an invalid extension for Dependencies (.sh instead of .json/.lock)',+ context: {+ applicationUniversalIdentifier: TEST_APP_ID,+ fileFolder: 'Dependencies',+ filePath: 'install.sh',+ failureLevel: 'file',+ },+ },+];++describe('Application file upload reservation should fail', () => {+ beforeAll(async () => {+ await setupApplicationForSync({+ applicationUniversalIdentifier: TEST_APP_ID,+ name: 'Test Upload Path Traversal App',+ description: 'App for testing path traversal on file upload',+ sourcePath: 'test-upload-path-traversal',+ });+ }, 60000);++ afterAll(async () => {+ await cleanupApplicationAndAppRegistration({+ applicationUniversalIdentifier: TEST_APP_ID,+ });+ });++ it.each(eachTestingContextFilter(FAILING_TEST_CASES))(+ '$title',+ async ({ context }) => {+ jest.useRealTimers();++ const { data, errors } = await createApplicationFileUploads({+ applicationUniversalIdentifier: context.applicationUniversalIdentifier,+ files: [+ {+ fileFolder: context.fileFolder,+ filePath: context.filePath,+ size: 'content'.length,+ },+ ],+ expectToFail: context.failureLevel === 'request',+ });++ jest.useFakeTimers();++ if (context.failureLevel === 'request') {+ expectOneNotInternalServerErrorSnapshot({ errors });++ return;+ }++ expect(errors).toBeUndefined();++ const { targets, errors: reservationErrors } =+ data.createApplicationFileUploads;++ expect(targets).toEqual([]);+ expect(reservationErrors).toEqual([+ {+ fileFolder: context.fileFolder,+ filePath: context.filePath,+ message: expect.any(String),+ },+ ]);+ expect(reservationErrors[0].message).toMatchSnapshot();+ },+ 60000,+ );+});diff --git a/packages/twenty-server/test/integration/metadata/suites/application/utils/upload-application-file-with-direct-upload.util.ts b/packages/twenty-server/test/integration/metadata/suites/application/utils/upload-application-file-with-direct-upload.util.tsnew file mode 100644index 00000000000..5a7f36e089a--- /dev/null+++ b/packages/twenty-server/test/integration/metadata/suites/application/utils/upload-application-file-with-direct-upload.util.ts@@ -0,0 +1,141 @@+import { completeApplicationFileUploadsQueryFactory } from 'test/integration/metadata/suites/application/utils/complete-application-file-uploads-query-factory.util';+import { type CompleteApplicationFileUploadsResult } from 'test/integration/metadata/suites/application/utils/complete-application-file-uploads.util';+import { createApplicationFileUploadsQueryFactory } from 'test/integration/metadata/suites/application/utils/create-application-file-uploads-query-factory.util';+import { type CreateApplicationFileUploadsResult } from 'test/integration/metadata/suites/application/utils/create-application-file-uploads.util';+import { putApplicationFileUploadTarget } from 'test/integration/metadata/suites/application/utils/put-application-file-upload-target.util';+import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';+import { isDefined, isNonEmptyArray } from 'twenty-shared/utils';++import { type BaseGraphQLError } from 'src/engine/core-modules/graphql/utils/graphql-errors.util';++type UploadedFile = {+ id: string;+ path: string;+};++type UploadApplicationFileError = Pick<BaseGraphQLError, 'message'>;++type UploadApplicationFileResult = {+ data: { uploadApplicationFile: UploadedFile } | undefined;+ errors: UploadApplicationFileError[] | undefined;+};++const toGraphqlErrors = (messages: string[]): UploadApplicationFileError[] =>+ messages.map((message) => ({ message }));++const runDirectUpload = async ({+ applicationUniversalIdentifier,+ fileFolder,+ filePath,+ fileBuffer,+ token,+}: {+ applicationUniversalIdentifier: string;+ fileFolder: string;+ filePath: string;+ fileBuffer: Buffer;+ token?: string;+}): Promise<UploadApplicationFileResult> => {+ const createResponse = await makeMetadataAPIRequest(+ createApplicationFileUploadsQueryFactory({+ applicationUniversalIdentifier,+ files: [{ fileFolder, filePath, size: fileBuffer.length }],+ }),+ token,+ );++ if (isDefined(createResponse.body.errors)) {+ return { data: undefined, errors: createResponse.body.errors };+ }++ const {+ targets,+ errors: reservationErrors,+ }: CreateApplicationFileUploadsResult =+ createResponse.body.data.createApplicationFileUploads;++ if (isNonEmptyArray(reservationErrors) || !isNonEmptyArray(targets)) {+ return {+ data: undefined,+ errors: toGraphqlErrors(reservationErrors.map(({ message }) => message)),+ };+ }++ const [uploadTarget] = targets;++ const putResponse = await putApplicationFileUploadTarget({+ uploadTarget,+ body: fileBuffer,+ });++ if (putResponse.status !== 204) {+ return {+ data: undefined,+ errors: toGraphqlErrors([+ `Upload to the file storage failed with status ${putResponse.status}`,+ ]),+ };+ }++ const completeResponse = await makeMetadataAPIRequest(+ completeApplicationFileUploadsQueryFactory({+ applicationUniversalIdentifier,+ fileIds: [uploadTarget.fileId],+ }),+ token,+ );++ if (isDefined(completeResponse.body.errors)) {+ return { data: undefined, errors: completeResponse.body.errors };+ }++ const {+ files,+ errors: completionErrors,+ }: CompleteApplicationFileUploadsResult =+ completeResponse.body.data.completeApplicationFileUploads;++ if (isNonEmptyArray(completionErrors) || !isNonEmptyArray(files)) {+ return {+ data: undefined,+ errors: toGraphqlErrors(completionErrors.map(({ message }) => message)),+ };+ }++ const [{ id, path }] = files;++ return { data: { uploadApplicationFile: { id, path } }, errors: undefined };+};++export const uploadApplicationFileWithDirectUpload = async ({+ applicationUniversalIdentifier,+ fileFolder,+ filePath,+ fileBuffer,+ expectToFail = false,+ token,+}: {+ applicationUniversalIdentifier: string;+ fileFolder: string;+ filePath: string;+ fileBuffer: Buffer;+ expectToFail?: boolean;+ token?: string;+}): Promise<UploadApplicationFileResult> => {+ const { data, errors } = await runDirectUpload({+ applicationUniversalIdentifier,+ fileFolder,+ filePath,+ fileBuffer,+ token,+ });++ if (expectToFail) {+ expect(errors).toBeDefined();+ } else {+ expect(errors).toBeUndefined();+ expect(data).toBeDefined();+ }++ return { data, errors };+};diff --git a/packages/twenty-server/test/integration/utils/create-app.ts b/packages/twenty-server/test/integration/utils/create-app.tsindex 3e3ffbdc9cf..24aca03703c 100644--- a/packages/twenty-server/test/integration/utils/create-app.ts+++ b/packages/twenty-server/test/integration/utils/create-app.ts@@ -73,7 +73,7 @@ export const createApp = async (app.use('/graphql',graphqlUploadExpress({- maxFieldSize: bytes(settings.storage.maxFileSize)!,+ maxFieldSize: bytes(settings.maxRequestBodySize)!,maxFiles: 10,}),);@@ -81,7 +81,7 @@ export const createApp = async (app.use('/metadata',graphqlUploadExpress({- maxFieldSize: bytes(settings.storage.maxFileSize)!,+ maxFieldSize: bytes(settings.maxRequestBodySize)!,maxFiles: 10,}),);