{"record":{"id":"6a5d5db0c610e87f","repo":"carrierwaveuploader/carrierwave","slug":"errors-messages-max-height-error","errorCode":null,"errorMessage":"errors.messages.max_height_error","messagePattern":"errors\\.messages\\.max_height_error","errorType":"exception","errorClass":"CarrierWave::IntegrityError","httpStatus":null,"severity":"error","filePath":"lib/carrierwave/uploader/dimension.rb","lineNumber":60,"sourceCode":"    private\n\n      def check_dimensions!(new_file)\n        # NOTE: Skip the check for resized images\n        return if version_name.present?\n        return unless width_range || height_range\n\n        unless respond_to?(:width) || respond_to?(:height)\n          raise 'You need to include one of CarrierWave::MiniMagick, CarrierWave::RMagick, or CarrierWave::Vips to perform image dimension validation'\n        end\n\n        if width_range&.begin && width < width_range.begin\n          raise CarrierWave::IntegrityError, I18n.translate(:\"errors.messages.min_width_error\", :min_width => ActiveSupport::NumberHelper.number_to_delimited(width_range.begin))\n        elsif width_range&.end && width > width_range.end\n          raise CarrierWave::IntegrityError, I18n.translate(:\"errors.messages.max_width_error\", :max_width => ActiveSupport::NumberHelper.number_to_delimited(width_range.end))\n        elsif height_range&.begin && height < height_range.begin\n          raise CarrierWave::IntegrityError, I18n.translate(:\"errors.messages.min_height_error\", :min_height => ActiveSupport::NumberHelper.number_to_delimited(height_range.begin))\n        elsif height_range&.end && height > height_range.end\n          raise CarrierWave::IntegrityError, I18n.translate(:\"errors.messages.max_height_error\", :max_height => ActiveSupport::NumberHelper.number_to_delimited(height_range.end))\n        end\n      end\n\n    end # Dimension\n  end # Uploader\nend # CarrierWave\n","sourceCodeStart":42,"sourceCodeEnd":67,"githubUrl":"https://github.com/carrierwaveuploader/carrierwave/blob/b5f0abe10ecf6500309fc83e0e8969cf57ba690e/lib/carrierwave/uploader/dimension.rb#L42-L67","documentation":"Raised as CarrierWave::IntegrityError when check_dimensions! sees an image taller than the upper bound of height_range (message errors.messages.max_height_error, bound formatted with delimiters). It is the last branch of the elsif chain (width bounds are checked first), applies to the base version only, and requires an image module (MiniMagick/RMagick/Vips) to supply height.","triggerScenarios":"Declaring height_range 600..2000 and uploading a 6000px-tall scroll-length screenshot or full-page capture; tall posters exported at print resolution.","commonSituations":"Screenshot-heavy products where full-page captures far exceed limits meant for photos; memory-driven caps (huge dimensions blow up processing) rejecting legitimate uploads; limits copied between uploaders with different content profiles.","solutions":["Raise the ceiling (height_range 100..8000) or cap at nil: height_range 100..nil, and downscale with process resize_to_limit: [nil, 2000] for stored versions instead of rejecting","Rescue CarrierWave::IntegrityError and return a clear 'image too tall, max X px' error","Enforce the same maximum in the client/upload widget before submission"],"exampleFix":"# before\nclass ScreenshotUploader < CarrierWave::Uploader::Base\n  include CarrierWave::MiniMagick\n  height_range 600..2000 # 6000px full-page capture -> IntegrityError max_height_error\nend\n\n# after\nclass ScreenshotUploader < CarrierWave::Uploader::Base\n  include CarrierWave::MiniMagick\n  process resize_to_limit: [nil, 4000]\n  height_range 100..nil\nend","handlingStrategy":"validation","validationCode":"require 'fastimage'\n\nMAX_H = 2000\nh = FastImage.size(params[:image].path)&.last\nreturn render_error(:too_tall) if h && h > MAX_H","typeGuard":"def within_height_range?(path, range)\n  _, h = FastImage.size(path)\n  !h.nil? && (range.begin.nil? || h >= range.begin) && (range.end.nil? || h <= range.end)\nend","tryCatchPattern":"begin\n  record.save!\nrescue CarrierWave::IntegrityError => e\n  record.errors.add(:image, :dimensions_invalid, message: e.message)\n  render :new\nend","preventionTips":["Use resize_to_limit to cap stored height instead of rejecting tall originals","Cap dimensions in the client/upload widget before POSTing large files","Set height ceilings per uploader based on real content (screenshots need much taller caps than avatars)"],"tags":["carrierwave","image-dimensions","validation","upload","height"],"backgroundTag":"image-dimension-rejected","analyzedSha":"b5f0abe10ecf6500309fc83e0e8969cf57ba690e","analyzedAt":"2026-08-21T18:07:27.715Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}