{"record":{"id":"d4d686d9ff17a9af","repo":"carrierwaveuploader/carrierwave","slug":"errors-messages-processing-error","errorCode":null,"errorMessage":"errors.messages.processing_error","messagePattern":"errors\\.messages\\.processing_error","errorType":"exception","errorClass":"CarrierWave::ProcessingError","httpStatus":null,"severity":"error","filePath":"lib/carrierwave/processing/mini_magick.rb","lineNumber":298,"sourceCode":"    #\n    # [MiniMagick::Image] manipulations to perform\n    #\n    # === Raises\n    #\n    # [CarrierWave::ProcessingError] if manipulation failed.\n    #\n    def manipulate!\n      cache_stored_file! if !cached?\n      image = ::MiniMagick::Image.open(current_path)\n\n      image = yield(image)\n      FileUtils.mv image.path, current_path\n\n      ::MiniMagick::Image.new(current_path).identify\n    rescue ::MiniMagick::Error, ::MiniMagick::Invalid => e\n      raise e if e.message =~ /(You must have .+ installed|is not installed|executable not found|delegate failed)/\n      message = I18n.translate(:\"errors.messages.processing_error\")\n      raise CarrierWave::ProcessingError, message\n    ensure\n      image.destroy! if image\n    end\n\n    # Process the image with MiniMagick, using the ImageProcessing gem. This\n    # method will build a \"convert\" ImageMagick command and execute it on the\n    # current image.\n    #\n    # === Gotcha\n    #\n    # This method assumes that the object responds to +current_path+.\n    # Any class that this module is mixed into must have a +current_path+ method.\n    # CarrierWave::Uploader does, so you won't need to worry about this in\n    # most cases.\n    #\n    # === Yields\n    #\n    # [ImageProcessing::Builder] use it to define processing to be performed","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/carrierwaveuploader/carrierwave/blob/b5f0abe10ecf6500309fc83e0e8969cf57ba690e/lib/carrierwave/processing/mini_magick.rb#L280-L316","documentation":"Raised as CarrierWave::ProcessingError (with the errors.messages.processing_error i18n message) by CarrierWave::MiniMagick#manipulate! when an image operation fails with ::MiniMagick::Error or ::MiniMagick::Invalid. The rescue deliberately re-raises errors whose message shows ImageMagick itself is missing ('You must have ... installed', 'is not installed', 'executable not found', 'delegate failed'); everything else (corrupt input, unsupported format, failed convert run) becomes this generic processing error.","triggerScenarios":"Declaring process in an uploader with the mini_magick module (e.g. process resize_to_fill: [200, 200]) and uploading a file the 'convert' binary cannot handle: a corrupted or zero-byte image, a non-image renamed to .jpg, or an obscure format ImageMagick lacks a coder for on the server.","commonSituations":"User uploads a file whose extension lies about its content; a truncated upload; hosting environments (slim Docker images, Alpine) missing ImageMagick delegates for the format being processed; upgrading ImageMagick changes format support or policy.xml restrictions.","solutions":["Sniff the real content type with Marcel (or a MiniMagick identify probe) before caching/processing and reject non-images","Rescue CarrierWave::ProcessingError in the controller/uploader callback and reject the upload with a friendly message","Verify ImageMagick is installed and the needed delegates exist on the server (convert -list format) — missing-binary errors re-raise with their own message","For policy/delegate issues, adjust /etc/ImageMagick-*/policy.xml or install the delegate packages"],"exampleFix":"# before\nprocess resize_to_fill: [200, 200] # corrupt file -> ProcessingError\n\n# after\nprocess resize_to_fill: [200, 200]\n\ndef validate_content_type(file)\n  type = Marcel::MimeType.from_path(file.path, magic: true)\n  raise CarrierWave::ProcessingError, :invalid_image unless type.start_with?('image/')\nend","handlingStrategy":"try-catch","validationCode":"require 'marcel'\n\ndef processable_image?(path)\n  Marcel::MimeType.from_path(path, magic: true).start_with?('image/')\nend\n\nbefore_cache do |file|\n  raise CarrierWave::ProcessingError, :invalid_image unless processable_image?(file.path)\nend","typeGuard":null,"tryCatchPattern":"begin\n  uploader.cache!(file)\n  uploader.store!\nrescue CarrierWave::ProcessingError\n  errors.add(:image, :processing_failed)\nend","preventionTips":["Sniff real content with Marcel (magic bytes) before any process block runs","Smoke-test the deployed host: ImageMagick installed and 'convert -list format' covers your accepted formats","Rescue CarrierWave::ProcessingError at the save site so a bad file becomes a validation error, not a 500"],"tags":["carrierwave","mini-magick","imagemagick","image-processing","upload"],"backgroundTag":"image-processing-failed","analyzedSha":"b5f0abe10ecf6500309fc83e0e8969cf57ba690e","analyzedAt":"2026-08-21T18:07:27.715Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}