googleapis/google-api-ruby-client

Youtube Video upload on sidekiq ( undefined method `each_with_index' for nil:NilClass )

farooqch11 opened this issue · 1 comments

Environment details

  • OS: linux, heroku
  • Ruby version: '3.1.2'
  • Gem name and version: Google::Apis::YoutubeV3::YouTubeService.new
  • Sidekiq

Steps to reproduce

  1. Working fine locally, when run on heroku and sidekiq , this method throws

@service.insert_video(
'id,snippet,status',
video_object,
upload_source: StringIO.new(HTTParty.get(url).parsed_response),
notify_subscribers: true,
content_type: 'video/mp4',
options: { authorization: client_options }
)

vendor/bundle/ruby/3.1.0/gems/representable-3.2.0/lib/representable/pipeline.rb:39:in call': undefined method `each_with_index' for nil:NilClass

  input.each_with_index do |item_fragment, i|
       ^^^^^^^^^^^^^^^^ (NoMethodError)
from vendor/bundle/ruby/3.1.0/gems/representable-3.2.0/lib/representable/pipeline.rb:19:in `evaluate'
from vendor/bundle/ruby/3.1.0/gems/representable-3.2.0/lib/representable/pipeline.rb:10:in `block in call'
from vendor/bundle/ruby/3.1.0/gems/representable-3.2.0/lib/representable/pipeline.rb:9:in `each'
from vendor/bundle/ruby/3.1.0/gems/representable-3.2.0/lib/representable/pipeline.rb:9:in `inject'
from vendor/bundle/ruby/3.1.0/gems/representable-3.2.0/lib/representable/pipeline.rb:9:in `call'
from vendor/bundle/ruby/3.1.0/gems/representable-3.2.0/lib/representable/binding.rb:50:in `compile_fragment'
from vendor/bundle/ruby/3.1.0/gems/representable-3.2.0/lib/representable/binding.rb:14:in `block in call'
from vendor/bundle/ruby/3.1.0/gems/representable-3.2.0/lib/representable/binding.rb:12:in `each'
from vendor/bundle/ruby/3.1.0/gems/representable-3.2.0/lib/representable/binding.rb:12:in `call'
from vendor/bundle/ruby/3.1.0/gems/representable-3.2.0/lib/representable.rb:68:in `representable_map!'
from vendor/bundle/ruby/3.1.0/gems/representable-3.2.0/lib/representable.rb:56:in `create_representation_with'
from vendor/bundle/ruby/3.1.0/gems/representable-3.2.0/lib/representable/hash.rb:37:in `to_hash'
from vendor/bundle/ruby/3.1.0/gems/representable-3.2.0/lib/representable/serializer.rb:45:in `block in <module:Representable>'
from vendor/bundle/ruby/3.1.0/gems/representable-3.2.0/lib/representable/pipeline.rb:19:in `evaluate'
from vendor/bundle/ruby/3.1.0/gems/representable-3.2.0/lib/representable/pipeline.rb:10:in `block in call'
from vendor/bundle/ruby/3.1.0/gems/representable-3.2.0/lib/representable/pipeline.rb:9:in `each'
from vendor/bundle/ruby/3.1.0/gems/representable-3.2.0/lib/representable/pipeline.rb:9:in `inject'
from vendor/bundle/ruby/3.1.0/gems/representable-3.2.0/lib/representable/pipeline.rb:9:in `call'
from vendor/bundle/ruby/3.1.0/gems/representable-3.2.0/lib/representable/binding.rb:50:in `compile_fragment'
from vendor/bundle/ruby/3.1.0/gems/representable-3.2.0/lib/representable/binding.rb:14:in `block in call'
from vendor/bundle/ruby/3.1.0/gems/representable-3.2.0/lib/representable/binding.rb:12:in `each'
from vendor/bundle/ruby/3.1.0/gems/representable-3.2.0/lib/representable/binding.rb:12:in `call'
from vendor/bundle/ruby/3.1.0/gems/representable-3.2.0/lib/representable.rb:68:in `representable_map!'
from vendor/bundle/ruby/3.1.0/gems/representable-3.2.0/lib/representable.rb:56:in `create_representation_with'
from vendor/bundle/ruby/3.1.0/gems/representable-3.2.0/lib/representable/hash.rb:37:in `to_hash'
from vendor/bundle/ruby/3.1.0/gems/representable-3.2.0/lib/representable/json.rb:42:in `to_json'
from vendor/bundle/ruby/3.1.0/gems/google-apis-core-0.9.5/lib/google/apis/core/api_command.rb:82:in `prepare!'
from vendor/bundle/ruby/3.1.0/gems/google-apis-core-0.9.5/lib/google/apis/core/upload.rb:51:in `prepare!'
from vendor/bundle/ruby/3.1.0/gems/google-apis-core-0.9.5/lib/google/apis/core/upload.rb:145:in `prepare!'
from vendor/bundle/ruby/3.1.0/gems/google-apis-core-0.9.5/lib/google/apis/core/http_command.rb:102:in `execute'
from vendor/bundle/ruby/3.1.0/gems/google-apis-core-0.9.5/lib/google/apis/core/base_service.rb:418:in `execute_or_queue_command'
from vendor/bundle/ruby/3.1.0/gems/google-api-client-0.53.0/generated/google/apis/youtube_v3/service.rb:3575:in `insert_video'
from app/services/youtube/api/youtube.rb:20:in `upload'
from app/workers/post_workflow/youtube_publish_worker.rb:27:in `perform'
from vendor/bundle/ruby/3.1.0/gems/redis-mutex-4.0.2/lib/redis_mutex/macro.rb:49:in `block (2 levels) in method_added'
from vendor/bundle/ruby/3.1.0/gems/redis-mutex-4.0.2/lib/redis_mutex.rb:80:in `with_lock'
from vendor/bundle/ruby/3.1.0/gems/redis-mutex-4.0.2/lib/redis_mutex.rb:125:in `with_lock'
from vendor/bundle/ruby/3.1.0/gems/redis-mutex-4.0.2/lib/redis_mutex/macro.rb:48:in `block in method_added'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-6.5.1/lib/sidekiq/processor.rb:196:in `execute_job'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-6.5.1/lib/sidekiq/processor.rb:164:in `block (2 levels) in process'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-6.5.1/lib/sidekiq/middleware/chain.rb:144:in `block in invoke'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-pro-5.5.1/lib/sidekiq/batch/middleware.rb:31:in `call'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-6.5.1/lib/sidekiq/middleware/chain.rb:146:in `block in invoke'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-ent-2.5.1/lib/sidekiq-ent/limiter/middleware.rb:39:in `call'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-6.5.1/lib/sidekiq/middleware/chain.rb:146:in `block in invoke'
from vendor/bundle/ruby/3.1.0/gems/bugsnag-6.24.2/lib/bugsnag/integrations/sidekiq.rb:24:in `call'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-6.5.1/lib/sidekiq/middleware/chain.rb:146:in `block in invoke'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-failures-1.0.1/lib/sidekiq/failures/middleware.rb:9:in `call'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-6.5.1/lib/sidekiq/middleware/chain.rb:146:in `block in invoke'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-6.5.1/lib/sidekiq/middleware/chain.rb:149:in `invoke'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-6.5.1/lib/sidekiq/processor.rb:163:in `block in process'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-6.5.1/lib/sidekiq/processor.rb:136:in `block (6 levels) in dispatch'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-6.5.1/lib/sidekiq/job_retry.rb:115:in `local'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-6.5.1/lib/sidekiq/processor.rb:135:in `block (5 levels) in dispatch'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-6.5.1/lib/sidekiq/rails.rb:14:in `block in call'
from vendor/bundle/ruby/3.1.0/gems/activesupport-6.1.4.4/lib/active_support/execution_wrapper.rb:88:in `wrap'
from vendor/bundle/ruby/3.1.0/gems/activesupport-6.1.4.4/lib/active_support/reloader.rb:72:in `block in wrap'
from vendor/bundle/ruby/3.1.0/gems/activesupport-6.1.4.4/lib/active_support/execution_wrapper.rb:88:in `wrap'
from vendor/bundle/ruby/3.1.0/gems/activesupport-6.1.4.4/lib/active_support/reloader.rb:71:in `wrap'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-6.5.1/lib/sidekiq/rails.rb:13:in `call'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-6.5.1/lib/sidekiq/processor.rb:131:in `block (4 levels) in dispatch'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-6.5.1/lib/sidekiq/processor.rb:257:in `stats'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-6.5.1/lib/sidekiq/processor.rb:126:in `block (3 levels) in dispatch'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-6.5.1/lib/sidekiq/job_logger.rb:13:in `call'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-6.5.1/lib/sidekiq/processor.rb:125:in `block (2 levels) in dispatch'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-6.5.1/lib/sidekiq/job_retry.rb:82:in `global'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-6.5.1/lib/sidekiq/processor.rb:124:in `block in dispatch'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-6.5.1/lib/sidekiq/job_logger.rb:39:in `prepare'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-6.5.1/lib/sidekiq/processor.rb:123:in `dispatch'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-6.5.1/lib/sidekiq/processor.rb:162:in `process'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-6.5.1/lib/sidekiq/processor.rb:78:in `process_one'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-6.5.1/lib/sidekiq/processor.rb:68:in `run'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-6.5.1/lib/sidekiq/component.rb:8:in `watchdog'
from vendor/bundle/ruby/3.1.0/gems/sidekiq-6.5.1/lib/sidekiq/component.rb:17:in `block in safe_thread'`

Code example

    video_object = Google::Apis::YoutubeV3::Video.new(
              status: Google::Apis::YoutubeV3::VideoStatus.new(privacy_status: privacy_status),
              snippet: Google::Apis::YoutubeV3::VideoSnippet.new(title: title, description: caption, tags: tags))

    @service.insert_video(
        'id,snippet,status',
        video_object,
        upload_source: StringIO.new(HTTParty.get(url).parsed_response),
        notify_subscribers: true,
        content_type: 'video/mp4',
        options: { authorization: client_options }
    )

Thanks!