{"record":{"id":"0449c1b1badd2db2","repo":"slymnoyann/hey-1","slug":"video-file-is-empty","errorCode":null,"errorMessage":"Video file is empty","messagePattern":"Video file is empty","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/helpers/generateVideoThumbnails.ts","lineNumber":6,"sourceCode":"const generateVideoThumbnails = async (\n  file: File,\n  count: number\n): Promise<string[]> => {\n  if (!file.size) {\n    throw new Error(\"Video file is empty\");\n  }\n\n  const url = URL.createObjectURL(file);\n  const video = document.createElement(\"video\");\n  const canvas = document.createElement(\"canvas\");\n  video.muted = true;\n  video.src = url;\n\n  try {\n    await new Promise<void>((resolve, reject) => {\n      video.onloadeddata = () => {\n        canvas.width = video.videoWidth;\n        canvas.height = video.videoHeight;\n        resolve();\n      };\n      video.onerror = () => reject(new Error(\"Failed to load video\"));\n    });\n","sourceCodeStart":1,"sourceCodeEnd":24,"githubUrl":"https://github.com/slymnoyann/hey-1/blob/88c8f9d55340d57a37846ff72f55c2c604e3a566/src/helpers/generateVideoThumbnails.ts#L1-L24","documentation":"Thrown by generateVideoThumbnails when the provided File object has a size of 0. The helper uses the browser's video/canvas APIs to seek through the video and capture frames, and an empty file cannot be loaded or decoded. This is an upfront sanity check before any DOM video work begins.","triggerScenarios":"Passing a File obtained from an <input type=\"file\"> or drag-drop where the file handle exists but the content is 0 bytes; a blob slice that produced an empty File; or a file that failed mid-read before being handed to the helper.","commonSituations":"User selects a video that is still syncing/downloading (0 bytes on disk), a canceled or interrupted upload/drag operation, constructing a File from an empty Blob, or a test fixture created with new File([], 'video.mp4').","solutions":["Check file.size > 0 in the file-picker change handler before calling generateVideoThumbnails","Verify the source of the File (input, drop, blob slice) actually contains data by logging file.size and file.type","If the file comes from a download/stream, wait until it is fully written before processing","Show a user-facing validation message asking them to re-select the video"],"exampleFix":"// before\nconst thumbs = await generateVideoThumbnails(file, 4);\n\n// after\nif (file.size === 0) {\n  throw new Error(\"Please select a non-empty video file\");\n}\nconst thumbs = await generateVideoThumbnails(file, 4);","handlingStrategy":"validation","validationCode":"if (!(file instanceof File) || file.size === 0) {\n  throw new Error(\"Video file is empty\");\n}\nconst isVideo = file.type.startsWith(\"video/\");\nif (!isVideo) {\n  throw new Error(\"Not a video file\");\n}","typeGuard":"const isNonEmptyFile = (f: unknown): f is File =>\n  f instanceof File && f.size > 0;","tryCatchPattern":"try {\n  const thumbs = await generateVideoThumbnails(file, count);\n} catch (e) {\n  if (e instanceof Error && e.message === \"Video file is empty\") {\n    // prompt user to re-select the file\n  }\n  throw e;\n}","preventionTips":["Validate file.size > 0 in the file input change handler","Reject 0-byte files at drag-drop time with a visible message","Avoid constructing File objects from unverified blob slices"],"tags":["video","file-validation","browser","thumbnails"],"backgroundTag":"empty-file-upload","analyzedSha":"88c8f9d55340d57a37846ff72f55c2c604e3a566","analyzedAt":"2026-08-28T16:20:43.640Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}