{"record":{"id":"dfc9765d0b3efa4d","repo":"RocketChat/Rocket.Chat","slug":"unknown-error","errorCode":null,"errorMessage":"Unknown error","messagePattern":"Unknown error","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/meteor/app/apps/server/bridges/uploads.ts","lineNumber":39,"sourceCode":"\t}\n\n\tprotected async getById(id: string, appId: string): Promise<IUpload> {\n\t\tthis.orch.debugLog(`The App ${appId} is getting the upload: \"${id}\"`);\n\n\t\t// #TODO: #AppsEngineTypes - Remove explicit types and typecasts once the apps-engine definition/implementation mismatch is fixed.\n\t\tconst promise: Promise<IUpload | undefined> = this.orch.getConverters()?.get('uploads').convertById(id);\n\t\treturn promise as Promise<IUpload>;\n\t}\n\n\tprotected async getBuffer(upload: IUpload, appId: string): Promise<Buffer> {\n\t\tthis.orch.debugLog(`The App ${appId} is getting the upload: \"${upload.id}\"`);\n\n\t\tconst rocketChatUpload = this.orch.getConverters()?.get('uploads').convertToRocketChat(upload);\n\n\t\tconst result = await FileUpload.getBuffer(rocketChatUpload);\n\n\t\tif (!(result instanceof Buffer)) {\n\t\t\tthrow new Error('Unknown error');\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tprotected async createUpload(details: IUploadDetails, buffer: Buffer, appId: string): Promise<IUpload> {\n\t\tthis.orch.debugLog(`The App ${appId} is creating an upload \"${details.name}\"`);\n\n\t\tif (!details.userId && !details.visitorToken) {\n\t\t\tthrow new Error('Missing user to perform the upload operation');\n\t\t}\n\n\t\tconst fileStore = FileUpload.getStore('Uploads');\n\n\t\tdetails.type = determineFileType(buffer, details.name);\n\n\t\tconst uploadedFile = await fileStore.insert(getUploadDetails(details), buffer);\n\t\tthis.orch.debugLog(`The App ${appId} has created an upload`, uploadedFile);","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/app/apps/server/bridges/uploads.ts#L21-L57","documentation":"UploadsBridge.getBuffer validates that FileUpload.getBuffer returns a Node Buffer; anything else (undefined, null, a non-Buffer stream result) collapses into the opaque 'Unknown error'. The real cause is the file store failing to produce the file's bytes — the store returned nothing rather than throwing, e.g. the file is missing from GridFS/the filesystem/S3.","triggerScenarios":"App reads an upload whose bytes are gone from the store (GridFS document deleted, file removed from disk, S3 object missing); S3-compatible store misconfiguration (wrong bucket/credentials/endpoint) making the read return empty; upload metadata record exists but the file itself is inconsistent.","commonSituations":"Database restored without the file store; S3 credential rotation; filesystem store path changed; the file was deleted while the app still held the IUpload object.","solutions":["Verify the file actually exists in the store (S3 bucket / GridFS collection / Uploads directory) and the store backend is reachable.","Check the FileUpload settings (storage type, path, bucket, region, credentials) in the admin UI.","If the bytes are gone, treat reads of that upload id as permanently failed and re-upload the file.","Server-side improvement: wrap the store read so the underlying store error is surfaced instead of 'Unknown error'."],"exampleFix":"// before\nconst buffer = await getBuffer(upload, appId); // throws 'Unknown error'\n\n// after - wrap and contextualize\ntry {\n  const buffer = await getBuffer(upload, appId);\n} catch (err) {\n  throw new Error(`Could not load file '${upload.name}' (${upload.id}) from the file store`, { cause: err });\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"const isBuffer = (b: unknown): b is Buffer => Buffer.isBuffer(b);","tryCatchPattern":"Catch, then wrap with upload id/name context and fail that single file; do not retry — missing store bytes will not reappear.","preventionTips":["Back up the file store together with the database.","Smoke-test an upload read after rotating S3 credentials or changing store settings.","Attach upload id and name to every buffer-read failure for supportability."],"tags":["apps-engine","uploads","file-storage","gridfs","s3"],"backgroundTag":"file-storage-read-failure","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}