teeparham / paperclip-meta

Adds width, height, and size to paperclip images.
MIT License
158 stars 97 forks source link

TypeError: incompatible marshal file format (can't be read) format version 4.8 required; 149.233 given #39

Open laptite opened 9 years ago

laptite commented 9 years ago

Scenario:

The existing meta, or original = instance.send("#{name}_meta") is returning a hash in a string format e.g. "{:length=>\"0:00:25.54\", :fps=>30, :size=>\"1920x1200\", :aspect=>1.6}". The TypeError exception is being thrown when Marshal.load can't make sense of the string returned by this call Base64.decode64(meta)

The below fix allows the video to be processed and returns the expected output when calling width or height on the uploaded video. Not saying it's ideal but it works for now.

def merge_existing_meta_hash(meta)
   return unless (original_meta = instance.send("#{name}_meta"))
   # meta.reverse_merge! meta_decode(original_meta) <-- original code
   meta.reverse_merge! eval(original_meta) <-- code that works
end

Full Backtrace:

/gems/activesupport-4.2.1/lib/active_support/core_ext/marshal.rb:6 in load
/gems/activesupport-4.2.1/lib/active_support/core_ext/marshal.rb:6 in load_with_autoloading
/gems/paperclip-meta-1.2.0/lib/paperclip-meta/attachment.rb:88 in meta_decode
/gems/paperclip-meta-1.2.0/lib/paperclip-meta/attachment.rb:95 in merge_existing_meta_hash
/gems/paperclip-meta-1.2.0/lib/paperclip-meta/attachment.rb:68 in write_meta
/gems/paperclip-meta-1.2.0/lib/paperclip-meta/attachment.rb:26 in post_process_styles_with_meta_data
[GEM_ROOT]/bundler/gems/paperclip-ac082d058ccc/lib/paperclip/attachment.rb:426 in block (2 levels) in post_process
/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:88 in call
/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:88 in _run_callbacks
/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:776 in _run_attachment_post_process_callbacks
/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:81 in run_callbacks
[GEM_ROOT]/bundler/gems/paperclip-ac082d058ccc/lib/paperclip/callbacks.rb:26 in run_paperclip_callbacks
[GEM_ROOT]/bundler/gems/paperclip-ac082d058ccc/lib/paperclip/attachment.rb:425 in block in post_process
/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:117 in call
/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:117 in call
/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:555 in block (2 levels) in compile
/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:505 in call
/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:505 in call
/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:92 in _run_callbacks
/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:776 in _run_post_process_callbacks
/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:81 in run_callbacks
[GEM_ROOT]/bundler/gems/paperclip-ac082d058ccc/lib/paperclip/callbacks.rb:26 in run_paperclip_callbacks
[GEM_ROOT]/bundler/gems/paperclip-ac082d058ccc/lib/paperclip/attachment.rb:424 in post_process
[GEM_ROOT]/bundler/gems/paperclip-ac082d058ccc/lib/paperclip/attachment.rb:108 in assign
[GEM_ROOT]/bundler/gems/paperclip-ac082d058ccc/lib/paperclip.rb:199 in block in has_attached_file
/gems/activerecord-4.2.1/lib/active_record/attribute_assignment.rb:54 in public_send
/gems/activerecord-4.2.1/lib/active_record/attribute_assignment.rb:54 in _assign_attribute
/gems/protected_attributes-1.0.9/lib/active_record/mass_assignment_security/attribute_assignment.rb:67 in block in assign_attributes
/gems/actionpack-4.2.1/lib/action_controller/metal/strong_parameters.rb:183 in each_pair
/gems/actionpack-4.2.1/lib/action_controller/metal/strong_parameters.rb:183 in each_pair
/gems/protected_attributes-1.0.9/lib/active_record/mass_assignment_security/attribute_assignment.rb:61 in assign_attributes
/gems/protected_attributes-1.0.9/lib/active_record/mass_assignment_security/nested_attributes.rb:144 in assign_to_or_mark_for_destruction
/gems/protected_attributes-1.0.9/lib/active_record/mass_assignment_security/nested_attributes.rb:57 in assign_nested_attributes_for_one_to_one_association
/gems/protected_attributes-1.0.9/lib/active_record/mass_assignment_security/nested_attributes.rb:37 in video_attributes=
/gems/activerecord-4.2.1/lib/active_record/attribute_assignment.rb:54 in public_send
/gems/activerecord-4.2.1/lib/active_record/attribute_assignment.rb:54 in _assign_attribute
/gems/activerecord-4.2.1/lib/active_record/attribute_assignment.rb:65 in block in assign_nested_parameter_attributes
/gems/activerecord-4.2.1/lib/active_record/attribute_assignment.rb:65 in each
/gems/activerecord-4.2.1/lib/active_record/attribute_assignment.rb:65 in assign_nested_parameter_attributes
/gems/protected_attributes-1.0.9/lib/active_record/mass_assignment_security/attribute_assignment.rb:71 in assign_attributes
[GEM_ROOT]/bundler/gems/activeadmin-b21ff811fee6/lib/active_admin/resource_controller/data_access.rb:175 in update_resource
/gems/inherited_resources-1.6.0/lib/inherited_resources/actions.rb:45 in update
app/admin/video_section.rb:73 in update
/gems/actionpack-4.2.1/lib/action_controller/metal/implicit_render.rb:4 in send_action
/gems/actionpack-4.2.1/lib/abstract_controller/base.rb:198 in process_action
/gems/actionpack-4.2.1/lib/action_controller/metal/rendering.rb:10 in process_action
/gems/actionpack-4.2.1/lib/abstract_controller/callbacks.rb:20 in block in process_action
/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:117 in call
/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:117 in call
/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:555 in block (2 levels) in compile
/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:505 in call
/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:505 in call
/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:92 in _run_callbacks
/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:776 in _run_process_action_callbacks
/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:81 in run_callbacks
/gems/actionpack-4.2.1/lib/abstract_controller/callbacks.rb:19 in process_action
/gems/actionpack-4.2.1/lib/action_controller/metal/rescue.rb:29 in process_action
/gems/sellect-2.2.9/config/initializers/oneline_detailed_logging.rb:29 in block (2 levels) in <top (required)>
/gems/activesupport-4.2.1/lib/active_support/notifications.rb:164 in block in instrument
/gems/activesupport-4.2.1/lib/active_support/notifications/instrumenter.rb:20 in instrument
/gems/activesupport-4.2.1/lib/active_support/notifications.rb:164 in instrument
/gems/sellect-2.2.9/config/initializers/oneline_detailed_logging.rb:28 in block in <top (required)>
/gems/actionpack-4.2.1/lib/action_controller/metal/params_wrapper.rb:250 in process_action
/gems/searchkick-0.8.7/lib/searchkick/logging.rb:107 in process_action
/gems/activerecord-4.2.1/lib/active_record/railties/controller_runtime.rb:18 in process_action
/gems/actionpack-4.2.1/lib/abstract_controller/base.rb:137 in process
/gems/actionview-4.2.1/lib/action_view/rendering.rb:30 in process
/gems/actionpack-4.2.1/lib/action_controller/metal.rb:196 in dispatch
/gems/actionpack-4.2.1/lib/action_controller/metal/rack_delegation.rb:13 in dispatch
/gems/actionpack-4.2.1/lib/action_controller/metal.rb:237 in block in action
/gems/actionpack-4.2.1/lib/action_dispatch/routing/route_set.rb:74 in call
/gems/actionpack-4.2.1/lib/action_dispatch/routing/route_set.rb:74 in dispatch
/gems/actionpack-4.2.1/lib/action_dispatch/routing/route_set.rb:43 in serve
/gems/actionpack-4.2.1/lib/action_dispatch/journey/router.rb:43 in block in serve
/gems/actionpack-4.2.1/lib/action_dispatch/journey/router.rb:30 in each
/gems/actionpack-4.2.1/lib/action_dispatch/journey/router.rb:30 in serve
/gems/actionpack-4.2.1/lib/action_dispatch/routing/route_set.rb:819 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/rack/agent_hooks.rb:30 in traced_call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/rack/browser_monitoring.rb:32 in traced_call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/rack-attack-4.3.0/lib/rack/attack.rb:104 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/warden-1.2.3/lib/warden/manager.rb:35 in block in call
/gems/warden-1.2.3/lib/warden/manager.rb:34 in catch
/gems/warden-1.2.3/lib/warden/manager.rb:34 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/rack-1.6.1/lib/rack/etag.rb:24 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/rack-1.6.1/lib/rack/conditionalget.rb:38 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/rack-1.6.1/lib/rack/head.rb:13 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/actionpack-xml_parser-1.0.2/lib/action_dispatch/xml_params_parser.rb:16 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/remotipart-1.2.1/lib/remotipart/middleware.rb:27 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/actionpack-4.2.1/lib/action_dispatch/middleware/params_parser.rb:27 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/actionpack-4.2.1/lib/action_dispatch/middleware/flash.rb:260 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/rack-1.6.1/lib/rack/session/abstract/id.rb:225 in context
/gems/rack-1.6.1/lib/rack/session/abstract/id.rb:220 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/actionpack-4.2.1/lib/action_dispatch/middleware/cookies.rb:560 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/activerecord-4.2.1/lib/active_record/query_cache.rb:36 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:649 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/actionpack-4.2.1/lib/action_dispatch/middleware/callbacks.rb:29 in block in call
/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:88 in call
/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:88 in _run_callbacks
/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:776 in _run_call_callbacks
/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:81 in run_callbacks
/gems/actionpack-4.2.1/lib/action_dispatch/middleware/callbacks.rb:27 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/actionpack-4.2.1/lib/action_dispatch/middleware/remote_ip.rb:78 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/actionpack-4.2.1/lib/action_dispatch/middleware/debug_exceptions.rb:17 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/actionpack-4.2.1/lib/action_dispatch/middleware/show_exceptions.rb:30 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/railties-4.2.1/lib/rails/rack/logger.rb:38 in call_app
/gems/railties-4.2.1/lib/rails/rack/logger.rb:20 in block in call
/gems/activesupport-4.2.1/lib/active_support/tagged_logging.rb:68 in block in tagged
/gems/activesupport-4.2.1/lib/active_support/tagged_logging.rb:26 in tagged
/gems/activesupport-4.2.1/lib/active_support/tagged_logging.rb:68 in tagged
/gems/railties-4.2.1/lib/rails/rack/logger.rb:20 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/actionpack-4.2.1/lib/action_dispatch/middleware/request_id.rb:21 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/rack-1.6.1/lib/rack/methodoverride.rb:22 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/rack-1.6.1/lib/rack/runtime.rb:18 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/activesupport-4.2.1/lib/active_support/cache/strategy/local_cache_middleware.rb:28 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/rack-1.6.1/lib/rack/sendfile.rb:113 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/rack-heartbeat-1.0.1/lib/rack/heartbeat.rb:27 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/railties-4.2.1/lib/rails/engine.rb:518 in call
/gems/railties-4.2.1/lib/rails/application.rb:164 in call
/gems/newrelic_rpm-3.12.0.288/lib/new_relic/agent/instrumentation/middleware_tracing.rb:67 in call
/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:580 in process_client
/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:674 in worker_loop
/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:529 in spawn_missing_workers
/gems/unicorn-4.9.0/lib/unicorn/http_server.rb:140 in start
/gems/unicorn-4.9.0/bin/unicorn:126 in <top (required)>
bin/unicorn:16 in load
bin/unicorn:16 in <main>
Envek commented 9 years ago

I faced with this issue too with Ruby on Rails 4.2.3, Ruby 2.2.2, Paperclip 4.3.0, and Paperclip-meta 1.2.0. @laptite your solution helps, thank you.

teeparham commented 9 years ago

Can we start with a failing test to reproduce this?

Envek commented 7 years ago

I'm sure this is a conflict with metadata from paperclip-av-transcoder gem, see https://github.com/ruby-av/paperclip-av-transcoder#meta-data