Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
brunosedler opened this issue Feb 26, 2024 · 0 comments
Open

Comments

@brunosedler
Copy link

brunosedler commented Feb 26, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant