{"record":{"id":"2744c47589d27afa","repo":"toeverything/AFFiNE","slug":"image-is-empty-or-invalid","errorCode":null,"errorMessage":"Image is empty or invalid","messagePattern":"Image is empty or invalid","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/frontend/apps/electron/src/main/ui/handlers.ts","lineNumber":226,"sourceCode":"    // see https://www.electronjs.org/docs/latest/tutorial/spellchecker#how-to-set-the-languages-the-spellchecker-uses\n    if (isMacOS()) {\n      return;\n    }\n\n    if (e.sender.session.availableSpellCheckerLanguages.includes(language)) {\n      e.sender.session.setSpellCheckerLanguages([language, 'en-US']);\n    }\n  },\n  captureArea: async (e, { x, y, width, height }: Electron.Rectangle) => {\n    const image = await e.sender.capturePage({\n      x: Math.floor(x),\n      y: Math.floor(y),\n      width: Math.floor(width),\n      height: Math.floor(height),\n    });\n\n    if (image.isEmpty()) {\n      throw new Error('Image is empty or invalid');\n    }\n\n    const buffer = image.toPNG();\n    if (!buffer || !buffer.length) {\n      throw new Error('Failed to generate PNG buffer from image');\n    }\n\n    clipboard.writeImage(nativeImage.createFromBuffer(buffer));\n  },\n} satisfies NamespaceHandlers;\n","sourceCodeStart":208,"sourceCodeEnd":237,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b6de0ad51b76f3daac2d3d6325369ea623ed7ed4/packages/frontend/apps/electron/src/main/ui/handlers.ts#L208-L237","documentation":"Thrown in the Electron `captureArea` IPC handler when `capturePage` returns an empty image for the requested rectangle — the region was zero-sized/off-screen or the renderer could not produce pixels. The capture fails fast with this error instead of writing an empty PNG.","triggerScenarios":"Thrown at packages/frontend/apps/electron/src/main/ui/handlers.ts:312 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide a non-empty, decodable image before calling this handler.","Check the source of the image (clipboard or file) for corruption.","Convert the image to a standard format (PNG/JPEG) and retry."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b6de0ad51b76f3daac2d3d6325369ea623ed7ed4","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}