Tag Archive | google

Google Api Drive V3 internal server error 500 on export

Google API is a good swissknife on our hands. It works very well but sometimes it’s behavior maybe strange too. Today I was coding ruby and using the google-api-client gem. Initially I managed my app to work very well. Using an instance of Google::Apis::DriveV3::DriveService my app copies a template (Google Docs) document to a new document, replaces placeholders and then gets the document pdf data by the “export_file” method (aka files.export). After approximately one hour and hundred documents processed my app started to hang on the export_file method reporting about a Server Error.

Exception Occurred Server error. Message: Server error.
Status code 500.
Header #.
Body {
"error": {
"errors": [
{
"domain": "global",
"reason": "internalError",
"message": "Internal Error"
}
],
"code": 500,
"message": "Internal Error"
}
}
.
/home/someone/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/google-apis-core-0.4.2/lib/google/apis/core/http_command.rb:232:in check_status' /home/someone/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/google-apis-core-0.4.2/lib/google/apis/core/api_command.rb:136:incheck_status'
/home/someone/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/google-apis-core-0.4.2/lib/google/apis/core/http_command.rb:195:in process_response' /home/someone/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/google-apis-core-0.4.2/lib/google/apis/core/http_command.rb:311:inexecute_once'
/home/someone/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/google-apis-core-0.4.2/lib/google/apis/core/http_command.rb:114:in block (2 levels) in execute' /home/someone/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/retriable-3.1.2/lib/retriable.rb:61:inblock in retriable'
/home/someone/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/retriable-3.1.2/lib/retriable.rb:56:in times' /home/someone/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/retriable-3.1.2/lib/retriable.rb:56:inretriable'
/home/someone/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/google-apis-core-0.4.2/lib/google/apis/core/http_command.rb:111:in block in execute' /home/someone/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/retriable-3.1.2/lib/retriable.rb:61:inblock in retriable'
/home/someone/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/retriable-3.1.2/lib/retriable.rb:56:in times' /home/someone/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/retriable-3.1.2/lib/retriable.rb:56:inretriable'
/home/someone/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/google-apis-core-0.4.2/lib/google/apis/core/http_command.rb:102:in execute' /home/someone/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/google-apis-core-0.4.2/lib/google/apis/core/base_service.rb:377:inexecute_or_queue_command'
/home/someone/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/google-api-client-0.53.0/generated/google/apis/drive_v3/service.rb:1036:in `export_file'

I was sure that nothing changed on my code so I started to search about something similar: people seem to have encountered my same problem but no one can provide a solution and btw suspects concentrate on quotas, access tokens and acls. Someone suggest to retry. So I checked my quotas (Google Cloud Console), I managed to reset my token and prepared a loop cycle to retry with a sleep period of 900 seconds. Nothing changed and problem remains.
After sometime spent on looking at similar issues on internet I started to think that some kind of DDoS/IPS technology on Google is causing my problem. That kind of technology may act at any level on Google platform and return a proper error code maybe not always possible (different subsystems interaction) or desired (risk to reveal trigger events).
Initially I changed my ip address by using a different internet connection: problem remained.
Then I changed my template document (simply copied it to another folder) and everything starts to work again.

I hope my experience can help you. Google is a complex system (an ecosystem) and think at it like a software (same input – same output) maybe the right way to waste your time (like i did!).