file_validators
file_validators copied to clipboard
Systematic crashes with carrierwave-aws when no file uploaded
I cannot seem to use the file_validators gem with carrierwave-aws. It systematically cause model crashes when saving without uploaded file. Apparently the file validations always trigger, even when there is no file, and that cause Aws::S3::Errors::NotFound:. I had to remove the gem from the Gemfile.
Here is a backtrace :
my_model_with_uploader.save
Aws::S3::Errors::NotFound:
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/gems/aws-sdk-core-2.3.11/lib/seahorse/client/plugins/raise_response_errors.rb:15:in `call'
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/gems/aws-sdk-core-2.3.11/lib/aws-sdk-core/plugins/s3_sse_cpk.rb:18:in `call'
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/gems/aws-sdk-core-2.3.11/lib/aws-sdk-core/plugins/s3_accelerate.rb:33:in `call'
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/gems/aws-sdk-core-2.3.11/lib/aws-sdk-core/plugins/param_converter.rb:20:in `call'
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/gems/aws-sdk-core-2.3.11/lib/seahorse/client/plugins/response_target.rb:21:in `call'
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/gems/aws-sdk-core-2.3.11/lib/seahorse/client/request.rb:70:in `send_request'
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/gems/aws-sdk-core-2.3.11/lib/seahorse/client/base.rb:207:in `block (2 levels) in define_operation_methods'
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/gems/aws-sdk-resources-2.3.11/lib/aws-sdk-resources/request.rb:24:in `call'
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/gems/aws-sdk-resources-2.3.11/lib/aws-sdk-resources/operations.rb:41:in `call'
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/gems/aws-sdk-resources-2.3.11/lib/aws-sdk-resources/operations.rb:61:in `call'
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/gems/aws-sdk-resources-2.3.11/lib/aws-sdk-resources/resource.rb:147:in `load'
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/gems/aws-sdk-resources-2.3.11/lib/aws-sdk-resources/resource.rb:120:in `data'
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/gems/aws-sdk-resources-2.3.11/lib/aws-sdk-resources/resource.rb:223:in `block in add_data_attribute'
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/gems/carrierwave-aws-1.0.1/lib/carrierwave/storage/aws_file.rb:7:in `content_type'
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/gems/carrierwave-0.10.0/lib/carrierwave/uploader/proxy.rb:83:in `content_type'
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/gems/file_validators-2.1.0/lib/file_validators/validators/file_content_type_validator.rb:65:in `get_content_type'
... 76 levels...
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/gems/activesupport-5.0.0.rc1/lib/active_support/callbacks.rb:750:in `_run_validation_callbacks'
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/gems/activemodel-5.0.0.rc1/lib/active_model/validations/callbacks.rb:113:in `run_validations!'
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/gems/activemodel-5.0.0.rc1/lib/active_model/validations.rb:338:in `valid?'
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/bundler/gems/mongoid-7c2ff52a0c52/lib/mongoid/validatable.rb:97:in `valid?'
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/gems/activemodel-5.0.0.rc1/lib/active_model/validations.rb:375:in `invalid?'
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/bundler/gems/mongoid-7c2ff52a0c52/lib/mongoid/persistable/updatable.rb:113:in `prepare_update'
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/bundler/gems/mongoid-7c2ff52a0c52/lib/mongoid/persistable/updatable.rb:137:in `update_document'
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/bundler/gems/mongoid-7c2ff52a0c52/lib/mongoid/persistable/savable.rb:25:in `save'
from (irb):2
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/gems/railties-5.0.0.rc1/lib/rails/commands/console.rb:65:in `start'
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/gems/railties-5.0.0.rc1/lib/rails/commands/console_helper.rb:9:in `start'
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/gems/railties-5.0.0.rc1/lib/rails/commands/commands_tasks.rb:78:in `console'
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/gems/railties-5.0.0.rc1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /var/www/mysite-prod/shared/bundle/ruby/2.3.0/gems/railties-5.0.0.rc1/lib/rails/commands.rb:18:in `<top (required)>'
from bin/rails:4:in `require'
Original issue there : https://github.com/sorentwo/carrierwave-aws/issues/86
@Startouf I've upgraded the detection of empty file and invalid file path in the new 2.2.0.beta1 release. Can you please check this out?