-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
Bug Description
When attempting to upload a file as an attachment to any record, the upload process fails. The browser's developer console shows a JavaScript error: Uncaught (in promise) Error: Should never occur, encountered unknown fields fileCategory in objectMetadataItem attachment.
This error prevents users from adding files to records, which is a critical functionality. The issue seems to stem from the client-side application sending a field (fileCategory) that the backend API does not expect during the file upload operation.
Application Version: v1.10.2
Expected behavior
A user should be able to select a file and upload it successfully as an attachment to a record. The file should appear in the attachments list without any errors.
Technical inputs
-
Error Stack Trace: The error originates from the frontend JavaScript code, as shown in the console:
Uncaught (in promise) Error: Should never occur, encountered unknown fields fileCategory in objectMetadataItem attachment at yR (index-Ckqrf0m1.js:5332:1221) at createOneRecord (index-Ckqrf0m1.js:5835:1026) at uploadAttachmentFile (index-Ckqrf0m1.js:9184:1352) at async c (index-Ckqrf0m1.js:9297:157) at async u (index-Ckqrf0m1.js:9297:200)
-
Problem Analysis: The error message strongly suggests a mismatch between the client and server data models. The frontend, specifically within the
createOneRecordfunction, appears to be adding afileCategoryfield to the attachment's metadata. However, the backend's GraphQL mutation for file uploads (uploadFile) does not recognize this field, leading to a rejection of the request. This could be due to a bug in the frontend logic or a version incompatibility. -
Failing Network Request (cURL):
Below is the structure of the failing network request, with all sensitive data (domain, tokens, cookies, filename) removed. It shows theuploadFilemutation sent to the GraphQL endpoint.curl 'https://[YOUR_TWENTY_DOMAIN]/graphql' \ -H 'accept: */*' \ -H 'authorization: Bearer [REDACTED_TOKEN]' \ -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundaryEXAMPLE' \ -H 'x-app-version: v1.10.2' \ --data-raw $'------WebKitFormBoundaryEXAMPLE\r\nContent-Disposition: form-data; name="operations"\r\n\r\n{"operationName":"uploadFile","variables":{"file":null,"fileFolder":"Attachment"},"query":"mutation uploadFile($file: Upload!, $fileFolder: FileFolder) {\\n uploadFile(file: $file, fileFolder: $fileFolder) {\\n path\\n token\\n __typename\\n }\\n}\\n"}\r\n------WebKitFormBoundaryEXAMPLE\r\nContent-Disposition: form-data; name="map"\r\n\r\n{"1":["variables.file"]}\r\n------WebKitFormBoundaryEXAMPLE\r\nContent-Disposition: form-data; name="1"; filename="example.pdf"\r\nContent-Type: application/pdf\r\n\r\n\r\n------WebKitFormBoundaryEXAMPLE--\r\n'
Metadata
Metadata
Assignees
Labels
Type
Projects
Status