I’ve been using the YouTube Data API v3/Google APIs Client Library for Ruby for over a year now to upload, update and delete videos automatically. I frequently receive errors from the API when trying to set the thumbnail image for a video right after it has been uploaded (something about a rate limit being exceeded and having to check some quota), but I am always well under the service quotas, there is no mention of the error in the documentation, and resubmitting the thumbnail always goes through so I just resubmit the thumbnail as needed. Most of the time everything works as expected.
Today, however, every time a video has been uploaded and a thumbnail was submitted, I’ve gotten a new error: failedPrecondition: Precondition check failed
This time, the error happens every time, and resubmitting does not help at all. Nothing has changed recently in my code, and everything else (uploading the video and the description) works as usual, so it does not seem to be a problem with authentication or a bad request. The images are small (less than 100K).
There is no mention of this exception in the Google developer documentation, so there is no way to know what could be wrong.
The code simply does a service.set_thumbnail(vid, upload_source: file)
, where vid
is the YouTube ID of the video and file
is the path to the image file. Again, this was working a couple of days ago.
The exception returned is:
failedPrecondition: Precondition check failed.
/home/uploader/local/ruby-3.2.1/lib/ruby/gems/3.2.0/gems/google-apis-core-0.11.1/lib/google/apis/core/http_command.rb:239:in `check_status'
/home/uploader/local/ruby-3.2.1/lib/ruby/gems/3.2.0/gems/google-apis-core-0.11.1/lib/google/apis/core/api_command.rb:135:in `check_status'
/home/uploader/local/ruby-3.2.1/lib/ruby/gems/3.2.0/gems/google-apis-core-0.11.1/lib/google/apis/core/http_command.rb:202:in `process_response'
/home/uploader/local/ruby-3.2.1/lib/ruby/gems/3.2.0/gems/google-apis-core-0.11.1/lib/google/apis/core/upload.rb:174:in `process_response'
/home/uploader/local/ruby-3.2.1/lib/ruby/gems/3.2.0/gems/google-apis-core-0.11.1/lib/google/apis/core/upload.rb:259:in `execute_once'
/home/uploader/local/ruby-3.2.1/lib/ruby/gems/3.2.0/gems/google-apis-core-0.11.1/lib/google/apis/core/http_command.rb:126:in `block (2 levels) in do_retry'
/home/uploader/local/ruby-3.2.1/lib/ruby/gems/3.2.0/gems/retriable-3.1.2/lib/retriable.rb:61:in `block in retriable'
/home/uploader/local/ruby-3.2.1/lib/ruby/gems/3.2.0/gems/retriable-3.1.2/lib/retriable.rb:56:in `times'
/home/uploader/local/ruby-3.2.1/lib/ruby/gems/3.2.0/gems/retriable-3.1.2/lib/retriable.rb:56:in `retriable'
/home/uploader/local/ruby-3.2.1/lib/ruby/gems/3.2.0/gems/google-apis-core-0.11.1/lib/google/apis/core/http_command.rb:123:in `block in do_retry'
/home/uploader/local/ruby-3.2.1/lib/ruby/gems/3.2.0/gems/retriable-3.1.2/lib/retriable.rb:61:in `block in retriable'
/home/uploader/local/ruby-3.2.1/lib/ruby/gems/3.2.0/gems/retriable-3.1.2/lib/retriable.rb:56:in `times'
/home/uploader/local/ruby-3.2.1/lib/ruby/gems/3.2.0/gems/retriable-3.1.2/lib/retriable.rb:56:in `retriable'
/home/uploader/local/ruby-3.2.1/lib/ruby/gems/3.2.0/gems/google-apis-core-0.11.1/lib/google/apis/core/http_command.rb:113:in `do_retry'
/home/uploader/local/ruby-3.2.1/lib/ruby/gems/3.2.0/gems/google-apis-core-0.11.1/lib/google/apis/core/http_command.rb:104:in `execute'
/home/uploader/local/ruby-3.2.1/lib/ruby/gems/3.2.0/gems/google-apis-core-0.11.1/lib/google/apis/core/base_service.rb:418:in `execute_or_queue_command'
/home/uploader/local/ruby-3.2.1/lib/ruby/gems/3.2.0/gems/google-apis-youtube_v3-0.6.0/lib/google/apis/youtube_v3/service.rb:3262:in `set_thumbnail'
/home/uploader/rails/app/controllers/concerns/youtube_handler.rb:63:in `block in set_thumbnail'
/home/uploader/rails/app/controllers/concerns/youtube_handler.rb:62:in `open'
/home/uploader/rails/app/controllers/concerns/youtube_handler.rb:62:in `set_thumbnail'
It looks like the library code tries three times to upload the image and gives up.
Has anyone encountered this error?