carrierwaveuploader/carrierwave · error · CarrierWave::IntegrityError
errors.messages.min_height_error
Error message
errors.messages.min_height_error
What it means
Raised as CarrierWave::IntegrityError when check_dimensions! sees an image shorter than the lower bound of height_range (message errors.messages.min_height_error, bound formatted via number_to_delimited). Same mechanics as the width checks: base version only, requires MiniMagick/RMagick/Vips for the height method, runs while the file is cached.
Source
Thrown at lib/carrierwave/uploader/dimension.rb:58
def height_range; end
private
def check_dimensions!(new_file)
# NOTE: Skip the check for resized images
return if version_name.present?
return unless width_range || height_range
unless respond_to?(:width) || respond_to?(:height)
raise 'You need to include one of CarrierWave::MiniMagick, CarrierWave::RMagick, or CarrierWave::Vips to perform image dimension validation'
end
if width_range&.begin && width < width_range.begin
raise CarrierWave::IntegrityError, I18n.translate(:"errors.messages.min_width_error", :min_width => ActiveSupport::NumberHelper.number_to_delimited(width_range.begin))
elsif width_range&.end && width > width_range.end
raise CarrierWave::IntegrityError, I18n.translate(:"errors.messages.max_width_error", :max_width => ActiveSupport::NumberHelper.number_to_delimited(width_range.end))
elsif height_range&.begin && height < height_range.begin
raise CarrierWave::IntegrityError, I18n.translate(:"errors.messages.min_height_error", :min_height => ActiveSupport::NumberHelper.number_to_delimited(height_range.begin))
elsif height_range&.end && height > height_range.end
raise CarrierWave::IntegrityError, I18n.translate(:"errors.messages.max_height_error", :max_height => ActiveSupport::NumberHelper.number_to_delimited(height_range.end))
end
end
end # Dimension
end # Uploader
end # CarrierWave
View on GitHub (pinned to b5f0abe10e)
Solutions
- Lower the height_range minimum to match real content (or remove the lower bound: height_range nil..2000)
- Show the required minimum dimensions in the upload UI and validate with a client-side check (e.g. HTML/JS reading naturalHeight)
- Rescue CarrierWave::IntegrityError and attach a specific 'image must be at least X px tall' validation message
Example fix
# before class CoverUploader < CarrierWave::Uploader::Base include CarrierWave::MiniMagick height_range 600..2000 # 1200x200 image -> IntegrityError min_height_error end # after class CoverUploader < CarrierWave::Uploader::Base include CarrierWave::MiniMagick height_range 150..2000 end
Defensive patterns
Strategy: validation
Validate before calling
require 'fastimage' MIN_H = 600 _h, h = nil, FastImage.size(params[:image].path)&.last return render_error(:too_short) if h && h < MIN_H
Type guard
def within_height_range?(path, range) _, h = FastImage.size(path) !h.nil? && (range.begin.nil? || h >= range.begin) && (range.end.nil? || h <= range.end) end
Try / catch
begin record.save! rescue CarrierWave::IntegrityError => e record.errors.add(:image, :dimensions_invalid, message: e.message) render :new end
Prevention
- Show required minimum dimensions in the upload UI and enforce them client-side (naturalHeight)
- Rescue CarrierWave::IntegrityError so short images get a specific validation message
- If short banners are legitimate, drop the lower bound: height_range nil..2000
When it happens
Trigger: Declaring height_range 600..2000 and uploading a 300px-tall banner or wide-but-short strip image (e.g. 1200x200).
Common situations: Banners/covers with hard height minimums rejecting legitimately short artwork; UI copy not telling users the minimum; cropping tools allowing crops below the configured floor.
Related errors
- errors.messages.max_height_error
- errors.messages.min_width_error
- errors.messages.max_width_error
- errors.messages.content_type_allowlist_error
- errors.messages.content_type_denylist_error
AI-assisted analysis of carrierwaveuploader/carrierwave@b5f0abe10e (2026-08-21).
Data as JSON: /api/errors/907b881db6bd4ffe.
Report an issue: GitHub.