{"record":{"id":"af1ebb144d1f5760","repo":"toeverything/AFFiNE","slug":"image-dimensions-exceed-limit","errorCode":null,"errorMessage":"image dimensions exceed limit","messagePattern":"image dimensions exceed limit","errorType":"validation","errorClass":"napi::Error","httpStatus":null,"severity":"error","filePath":"packages/backend/native/src/image.rs","lineNumber":92,"sourceCode":"    preserve_exif(input, format, &mut output)?;\n  }\n\n  Ok(output)\n}\n\nfn read_dimensions(input: &[u8], format: ImageFormat) -> AnyResult<(u32, u32)> {\n  ImageReader::with_format(Cursor::new(input), format)\n    .into_dimensions()\n    .context(\"failed to decode image\")\n}\n\nfn validate_dimensions(width: u32, height: u32) -> AnyResult<()> {\n  if width == 0 || height == 0 {\n    bail!(\"failed to decode image\");\n  }\n\n  if width > MAX_IMAGE_DIMENSION || height > MAX_IMAGE_DIMENSION {\n    bail!(\"image dimensions exceed limit\");\n  }\n\n  if u64::from(width) * u64::from(height) > MAX_IMAGE_PIXELS {\n    bail!(\"image pixel count exceeds limit\");\n  }\n\n  Ok(())\n}\n\nfn decode_image(input: &[u8], format: ImageFormat) -> AnyResult<DynamicImage> {\n  Ok(match format {\n    ImageFormat::Gif => {\n      let decoder = GifDecoder::new(Cursor::new(input)).context(\"failed to decode image\")?;\n      let frame = decoder\n        .into_frames()\n        .next()\n        .transpose()\n        .context(\"failed to decode image\")?","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/backend/native/src/image.rs#L74-L110","documentation":"validate_dimensions in the native image processor rejects images whose width or height exceeds MAX_IMAGE_DIMENSION; oversized images bail! with this error before processing. Called from process_image_inner.","triggerScenarios":"Raised in validate_dimensions when a decoded image width or height exceeds MAX_IMAGE_DIMENSION.","commonSituations":"The source image is extremely large on one axis (e.g. a huge panorama or scan). Downscale it externally below the dimension limit before processing.","solutions":["Downscale the image before processing.","Raise the dimension limit only if memory allows."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}