rake paperclip:refresh failing with No such Key #808

Closed
Fabs opened this Issue Apr 1, 2012 · 10 comments

4 participants

@Fabs

I'm running:

rake paperclip:refresh class=Challenge --verbose

Half of my assets are correctly refreshed, but something happens in the middle of the refreshing, and results in this error:

rake aborted!
No Such Key

Tasks: TOP => paperclip:refresh => paperclip:refresh:metadata
(See full trace by running task with --trace)
bundle exec rake paperclip:refresh class=Challenge --verbose 25.76s user 3.62s system 61% cpu 47.953 total

Assets are on amazon s3
ruby 1.9.2
rails 3.2.0
paperclip (2.7.0)

@Fabs

has_attached_file :image,
:storage => :s3,
:bucket => 'poptaskmvp2',
:s3_credentials => {
:access_key_id => "key",
:secret_access_key => "secret"
},
:default_image => "http://poptaskmvp2.s3.amazonaws.com/missing.png",
:path => "images/:id/:style/:basename.:extension",
:styles => { :thumb => ["220x220>", :png], :city => ["220x220", :png]}

@jyurek
thoughtbot, inc. member

What happens with you run with --trace? Also, have you tried the latest version of Paperclip instead of 2.7.0?

@Fabs

Here is the trace:

[master 0-poptask] rake paperclip:refresh class=Challenge --verbose --trace
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/01/04/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /Volumes/Sensitive/fabsn/daily/0-poptask/Rakefile:7)
** Invoke paperclip:refresh (first_time)
** Invoke paperclip:refresh:metadata (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute paperclip:refresh:metadata
rake aborted!
No Such Key
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/aws-sdk-1.3.9/lib/aws/core/client.rb:277:in `return_or_raise'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/aws-sdk-1.3.9/lib/aws/core/client.rb:362:in `client_request'
(eval):3:in `get_object'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/aws-sdk-1.3.9/lib/aws/s3/s3_object.rb:707:in `read'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/paperclip-2.7.0/lib/paperclip/storage/s3.rb:271:in `to_file'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/paperclip-2.7.0/lib/tasks/paperclip.rake:48:in `block (5 levels) in <top (required)>'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/paperclip-2.7.0/lib/paperclip.rb:146:in `block (2 levels) in each_instance_with_attachment'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/paperclip-2.7.0/lib/paperclip.rb:145:in `each'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/paperclip-2.7.0/lib/paperclip.rb:145:in `block in each_instance_with_attachment'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.2.0/lib/active_record/scoping/default.rb:41:in `block in unscoped'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.2.0/lib/active_record/relation.rb:240:in `block in scoping'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.2.0/lib/active_record/scoping.rb:98:in `with_scope'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.2.0/lib/active_record/relation.rb:240:in `scoping'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.2.0/lib/active_record/scoping/default.rb:41:in `unscoped'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/paperclip-2.7.0/lib/paperclip.rb:144:in `each_instance_with_attachment'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/paperclip-2.7.0/lib/tasks/paperclip.rake:47:in `block (4 levels) in <top (required)>'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/paperclip-2.7.0/lib/tasks/paperclip.rake:46:in `each'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/paperclip-2.7.0/lib/tasks/paperclip.rake:46:in `block (3 levels) in <top (required)>'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/fabsn/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/Users/fabsn/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/bin/rake:19:in `load'
/Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/bin/rake:19:in `<main>'
Tasks: TOP => paperclip:refresh => paperclip:refresh:metadata
rake paperclip:refresh class=Challenge --verbose --trace  25.57s user 3.67s system 11% cpu 4:17.38 total

I am using this version because I have another error with the current version of paperclip. I don't remember which one but its related with São Paulo s3 region of aws.

@sikachu
thoughtbot, inc. member

Hmm .. it's kinda hard for me to debug this as well, as normally this would mean there's some inconsistency between the database and S3, as we can't resolve the path to the file (i.e. file was missing.)

I'm pushing this one to target 3.1, because I think the rake task need to be rewritten and unit-tested. I'll make sure that it fails silently with a nice error message when something is wrong.

@sikachu sikachu was assigned May 4, 2012
@Fabs

OK. Sorry for such a late response. I have switched to another project, and using a new combination of paperclip and rails where it does not happening anymore.

Thanks for your effort guys :-), I guess its it for now.

@Fabs Fabs closed this May 11, 2012
@gosuri

@Fabs This happens when the aws-sdk gem cannot find the file (the key)

To debug:

  1. edit /Volumes/Sensitive/home/.rvm/gems/ruby-1.9.2-p0/gems/aws-sdk-1.3.9/lib/aws/s3/s3_object.rb
  2. output the bucket and key (around line 706):
  puts "bucket => #{bucket.name}, :key => #{key}"

The read method should look like this:

def read(options = {}, &blk)
  options[:bucket_name] = bucket.name
  options[:key] = key
  puts "DEBUG: bucket: #{bucket.name}, key: #{key}"
  client.get_object(options).data[:data]
end
  1. Check if the file exists, if not created it.

@sikachu - Graceful messages will help.

@sikachu sikachu reopened this May 18, 2012
@sikachu
thoughtbot, inc. member

Totally. I didn't see that this one was closed — still want to output a good debug information for 3.1

@Fabs

Thanks @gosuri. Sorry @sikachu , I misunderstood your last comment and thought I was the one holding it open.

@sikachu
thoughtbot, inc. member
@sikachu
thoughtbot, inc. member

Closing this since #1260 includes a better Exception handling.

@sikachu sikachu closed this Jul 26, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment