{"record":{"id":"dfc9765d0b3efa4d","repo":"RocketChat/Rocket.Chat","slug":"unknown-error","errorCode":null,"errorMessage":"Unknown error","messagePattern":"Unknown error","errorType":"exception","errorClass":"Error","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/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/app/apps/server/bridges/uploads.ts#L21-L57","documentation":"Thrown by getBuffer when FileUpload.getBuffer returns something that is not a Buffer instance. The upload store is expected to yield a Node Buffer for the file's bytes; any other shape (null, stream, corrupted/empty data) triggers a deliberately opaque 'Unknown error' because the bridge cannot expose store internals.","triggerScenarios":"App requests the byte buffer of an upload whose underlying file is missing from the store, corrupted, stored in a backend that did not return raw bytes, or whose retrieval returned an unexpected type.","commonSituations":"Upload was deleted from the file store but its metadata remains; misconfigured S3/GridFS/filesystem store returning an error object instead of bytes; upload older than a retention cleanup; storage backend migration left dangling files.","solutions":["Confirm the upload id still resolves to a real file via getById before requesting its buffer.","Verify the FileUpload store backend is healthy and the file is present on disk/storage.","Catch the error and report to the user that the file could not be read."],"exampleFix":"// before\nconst buf = await read.getUploadReader().getBufferById(id);\n\n// after\nconst upload = await read.getUploadReader().getById(id);\nif (!upload) {\n  // upload no longer exists; bail\n  return;\n}\nlet buf;\ntry {\n  buf = await read.getUploadReader().getBufferById(id);\n} catch {\n  // file store could not return bytes\n  return;\n}","handlingStrategy":"validation","validationCode":"const upload = await read.getUploadReader().getById(id);\nif (!upload) {\n  throw new Error('Upload not found; cannot read buffer');\n}","typeGuard":"import { Buffer } from 'buffer';\nfunction isBuffer(val: unknown): val is Buffer {\n  return Buffer.isBuffer(val);\n}","tryCatchPattern":"try {\n  const buf = await read.getUploadReader().getBufferById(id);\n} catch (err) {\n  if (err instanceof Error && err.message === 'Unknown error') {\n    // file store could not return bytes — report to user\n  } else {\n    throw err;\n  }\n}","preventionTips":["Confirm the upload still exists via getById before reading bytes.","Keep the FileUpload backend healthy and check dangling files after migrations.","Treat 'Unknown error' from getBuffer as a storage-layer problem."],"tags":["apps-engine","uploads","file-storage","buffer"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}