instructure/canvas-lms · warning

MiniMagick processing failed: #

Error message

MiniMagick processing failed: #{e}

What it means

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.

Solutions

  1. Verify ImageMagick works on the host: `identify -list format` for the offending format
  2. Check /etc/ImageMagick-*/policy.xml for rights="none" entries blocking the format
  3. Validate/repair the uploaded image (file size, actual format via `file`) before processing
  4. Ensure the attachment model handles nil width/height gracefully since processing silently no-ops

Example fix

// before
img.combine_options { |c| c.resize('300x300') } # MiniMagick::Error swallowed
// after
unless img.valid? && img.type.in?(SUPPORTED_TYPES)
  raise AttachmentFu::UnsupportedImage, "unsupported image #{img.path}"
end
img.combine_options { |c| c.resize('300x300') }
Defensive patterns

Strategy: validation

Validate before calling

# validate before handing to MiniMagick
raise AttachmentFu::BadImage unless File.size(path) > 0
raise AttachmentFu::BadImage unless SUPPORTED_MIMES.include?(MimeMagic.by_path(path)&.type)

Try / catch

begin
  attachment.process_attachment
rescue AttachmentFu::BadImage
  logger.warn("skipping unprocessable attachment #{attachment.id}")
end

Prevention

When it happens

Trigger: 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.

Common situations: ImageMagick security policy (policy.xml) disallowing PDF/HTTPS delegates; upgrading ImageMagick and losing a delegate; users uploading truncated or mislabeled image files.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


AI-assisted analysis of instructure/canvas-lms@1c9f0bb801 (2026-09-15). Data as JSON: /api/errors/ef3cca8c57d6ac1c. Report an issue: GitHub.

Appendix: source

Thrown at gems/attachment_fu/lib/attachment_fu/processors/mini_magick_processor.rb:60

      protected

      def process_attachment
        return unless super

        if image? && !@resized
          with_image do |img|
            max_image_size = attachment_options[:thumbnail_max_image_size_pixels]
            raise ThumbnailError, "source image too large" if max_image_size && img[:width] * img[:height] > max_image_size

            resize_image_or_thumbnail! img
            self.width = img[:width] if respond_to?(:width)
            self.height = img[:height] if respond_to?(:height)
            @resized = true
          end
        end
      rescue MiniMagick::Error => e
        logger.warn("MiniMagick processing failed: #{e}")
      end

      # Performs the actual resizing operation for a thumbnail
      def resize_image(img, size)
        size = size.first if size.is_a?(Array) && size.length == 1
        img.combine_options do |commands|
          commands.strip unless attachment_options[:keep_profile]

          commands.limit("area", "100MB")
          commands.limit("disk", "1000MB") # because arbitrary numbers are arbitrary

          # gif are not handled correct, this is a hack, but it seems to work.
          if img[:format].include?("GIF")
            img.format("png")
          end

          if size.is_a?(Integer) || (size.is_a?(Array) && size.first.is_a?(Integer))
            if size.is_a?(Integer)

View on GitHub (pinned to 1c9f0bb801)