Skip to content

#{column}_download_errors is not cleared on reassigning remote url  #2725

@brunosedler

Description

@brunosedler

When reassign a remote URLs, previous errors are not cleared.

Example Code (Rails)

class BlogArticle < ActiveRecord::Base
  mount_uploader :image, ImageUploader
end

class BlogArticle::ImageUploader < CarrierWave::Uploader::Base
  def extension_allowlist
    %w[jpg jpeg gif png]
  end
end

Steps to reproduce

article = BlogArticle.new

# Ensure tested URL is valid
article.remote_image_url = "https://fastly.picsum.photos/id/521/200/300.jpg?hmac=_MGlU-tHw5IBlsNL7YvJ9lTMo4Ge605GWQwuKGxWIWU"
article.valid?
# => true

Assign invalid URL
article.remote_image_url =  "https://fastly.picsum.photos/id/521/200/invalid.jpg"
article.valid?
# => false

article.image_download_errors
# => [#<CarrierWave::DownloadError: could not download file: 404 "Not Found">]

article.errors.messages[:image]
["could not download file: 404 \"Not Found\""]


# Re-assign valid URL
article.remote_image_url = "https://fastly.picsum.photos/id/521/200/300.jpg?hmac=_MGlU-tHw5IBlsNL7YvJ9lTMo4Ge605GWQwuKGxWIWU"
article.valid?
# => false 
# should be true

article.image_download_errors
# => [#<CarrierWave::DownloadError: could not download file: 404 "Not Found">]
# should be empty

article.errors.messages[:image]
# => ["could not download file: 404 \"Not Found\"]
# should be empty

Further Infos:
I'm using Rails 6.1.7.2, Ruby 2.7.6 and CarrierWave 3.0.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions