{"record":{"id":"e196dabdd142d6a8","repo":"transloadit/uppy","slug":"file-data-is-empty","errorCode":null,"errorMessage":"File data is empty","messagePattern":"File data is empty","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@uppy/thumbnail-generator/src/index.ts","lineNumber":208,"sourceCode":"    this.thumbnailType = this.opts.thumbnailType\n\n    this.defaultLocale = locale\n\n    this.i18nInit()\n\n    if (this.opts.lazy && this.opts.waitForThumbnailsBeforeUpload) {\n      throw new Error(\n        'ThumbnailGenerator: The `lazy` and `waitForThumbnailsBeforeUpload` options are mutually exclusive. Please ensure at most one of them is set to `true`.',\n      )\n    }\n  }\n\n  createThumbnail(\n    file: LocalUppyFile<M, B>,\n    targetWidth: number | null,\n    targetHeight: number | null,\n  ): Promise<string> {\n    if (file.data == null) throw new Error('File data is empty')\n    const originalUrl = URL.createObjectURL(file.data)\n\n    const onload = new Promise<HTMLImageElement>((resolve, reject) => {\n      const image = new Image()\n      image.src = originalUrl\n      image.addEventListener('load', () => {\n        URL.revokeObjectURL(originalUrl)\n        resolve(image)\n      })\n      image.addEventListener('error', (event) => {\n        URL.revokeObjectURL(originalUrl)\n        reject(event.error || new Error('Could not create thumbnail'))\n      })\n    })\n\n    const orientationPromise = rotation(file.data).catch(\n      () => 1,\n    ) as Promise<Rotation>","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/transloadit/uppy/blob/5d4dedd02a1ac0ae022c75c54aca76558f88e256/packages/@uppy/thumbnail-generator/src/index.ts#L190-L226","documentation":"createThumbnail throws when file.data is null/undefined — there is no Blob to load into an Image for downscaling. Typically the file object exists in state but its raw data was stripped (e.g. after a page restore or programmatic reconstruction), so a thumbnail cannot be generated.","triggerScenarios":"ThumbnailGenerator.requestThumbnail -> createThumbnail for a file whose data is null. Happens with files restored from Golden Retriever where blob recovery failed, files created via uppy.addFile with meta only and a preview but no data, or after data was deliberately cleared post-upload.","commonSituations":"Golden Retriever restoring file state after a crash without actual blobs; custom code calling uppy.addFile({data: null, previewURL}) to fake entries; race where thumbnails are requested after uppy.removeFile cleared data.","solutions":["Guard before requesting thumbnails: skip files with no data in a thumbnail:all handler or your custom scheduling","Ensure uppy.addFile is always given a real Blob/File in data","After Golden Retriever restores, mark restored files as not previewable or let users re-add them","Catch per-file thumbnail errors ('thumbnail:error') instead of letting them reject globally"],"exampleFix":"// before\nuppy.addFile({ name: 'x.png', type: 'image/png', data: null, meta: {} })\n// -> thumbnail request throws 'File data is empty'\n\n// after\nuppy.addFile({\n  name: 'x.png',\n  type: 'image/png',\n  data: new Blob([...], { type: 'image/png' }),\n})","handlingStrategy":"validation","validationCode":"const files = Object.values(uppy.getState().files)\nconst withData = files.filter((f) => f.data != null)\n// only these are eligible for thumbnail generation","typeGuard":"function hasFileData(file: { data?: Blob | null }): file is { data: Blob } {\n  return file.data != null\n}","tryCatchPattern":"uppy.on('thumbnail:error', (file, err) => {\n  if (err.message === 'File data is empty') uppy.setFilePreview(file.id, placeholderIcon)\n})","preventionTips":["Always pass a real Blob/File in addFile's data","Don't request thumbnails for restored/Golden-Retriever files without blobs","Guard custom thumbnail scheduling with hasFileData"],"tags":["thumbnail-generator","file-data","null-data"],"backgroundTag":"null-file-data","analyzedSha":"5d4dedd02a1ac0ae022c75c54aca76558f88e256","analyzedAt":"2026-08-28T12:18:41.267Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}