{"record":{"id":"ef3cca8c57d6ac1c","repo":"instructure/canvas-lms","slug":"minimagick-processing-failed-e","errorCode":null,"errorMessage":"MiniMagick processing failed: #{e}","messagePattern":"MiniMagick processing failed: #(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"gems/attachment_fu/lib/attachment_fu/processors/mini_magick_processor.rb","lineNumber":60,"sourceCode":"\n      protected\n\n      def process_attachment\n        return unless super\n\n        if image? && !@resized\n          with_image do |img|\n            max_image_size = attachment_options[:thumbnail_max_image_size_pixels]\n            raise ThumbnailError, \"source image too large\" if max_image_size && img[:width] * img[:height] > max_image_size\n\n            resize_image_or_thumbnail! img\n            self.width = img[:width] if respond_to?(:width)\n            self.height = img[:height] if respond_to?(:height)\n            @resized = true\n          end\n        end\n      rescue MiniMagick::Error => e\n        logger.warn(\"MiniMagick processing failed: #{e}\")\n      end\n\n      # Performs the actual resizing operation for a thumbnail\n      def resize_image(img, size)\n        size = size.first if size.is_a?(Array) && size.length == 1\n        img.combine_options do |commands|\n          commands.strip unless attachment_options[:keep_profile]\n\n          commands.limit(\"area\", \"100MB\")\n          commands.limit(\"disk\", \"1000MB\") # because arbitrary numbers are arbitrary\n\n          # gif are not handled correct, this is a hack, but it seems to work.\n          if img[:format].include?(\"GIF\")\n            img.format(\"png\")\n          end\n\n          if size.is_a?(Integer) || (size.is_a?(Array) && size.first.is_a?(Integer))\n            if size.is_a?(Integer)","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/instructure/canvas-lms/blob/1c9f0bb8013ed69c4f2efe11fd483025469b7e6c/gems/attachment_fu/lib/attachment_fu/processors/mini_magick_processor.rb#L42-L78","documentation":"The attachment_fu MiniMagick processor wraps image transformation in a rescue for MiniMagick::Error. When ImageMagick fails (corrupt file, unsupported format, missing delegate), the processor logs a warning and leaves the attachment without resized dimensions instead of raising. The attachment upload succeeds but thumbnails/resizes may be missing.","triggerScenarios":"process_attachment -> resize_image invokes img.combine_options and MiniMagick raises MiniMagick::Error — e.g., identify/convert fails on a corrupt or zero-byte image, an unsupported format (CMYK TIFF oddities), or an ImageMagick policy/delegate blocks the operation.","commonSituations":"ImageMagick security policy (policy.xml) disallowing PDF/HTTPS delegates; upgrading ImageMagick and losing a delegate; users uploading truncated or mislabeled image files.","solutions":["Verify ImageMagick works on the host: `identify -list format` for the offending format","Check /etc/ImageMagick-*/policy.xml for rights=\"none\" entries blocking the format","Validate/repair the uploaded image (file size, actual format via `file`) before processing","Ensure the attachment model handles nil width/height gracefully since processing silently no-ops"],"exampleFix":"// before\nimg.combine_options { |c| c.resize('300x300') } # MiniMagick::Error swallowed\n// after\nunless img.valid? && img.type.in?(SUPPORTED_TYPES)\n  raise AttachmentFu::UnsupportedImage, \"unsupported image #{img.path}\"\nend\nimg.combine_options { |c| c.resize('300x300') }","handlingStrategy":"validation","validationCode":"# validate before handing to MiniMagick\nraise AttachmentFu::BadImage unless File.size(path) > 0\nraise AttachmentFu::BadImage unless SUPPORTED_MIMES.include?(MimeMagic.by_path(path)&.type)","typeGuard":null,"tryCatchPattern":"begin\n  attachment.process_attachment\nrescue AttachmentFu::BadImage\n  logger.warn(\"skipping unprocessable attachment #{attachment.id}\")\nend","preventionTips":["Verify ImageMagick delegates and policy.xml after every ImageMagick upgrade","Run `identify` on uploads in a smoke test","Handle nil width/height on attachments produced by failed processing"],"tags":["image-processing","imagemagick","mini-magick","attachments"],"backgroundTag":"http-request-failed","analyzedSha":"1c9f0bb8013ed69c4f2efe11fd483025469b7e6c","analyzedAt":"2026-09-15T20:33:18.891Z","contentChangedAt":"2026-09-15T20:33:18.891Z","schemaVersion":2},"datasetVersion":"2026-09-23T02:17:17.105Z"}