Open sampenguin opened 3 months ago
A few clarifying questions:
rails server
? Do you have any fancy auto-reloading or process caching system like bootsnap running in your Rails setup, and if so can you try turning those off?rails server
, bundle exec sidekiq
etc. so there is nothing fancy or automated in my development environment.
When I execute the successful standalone script, it's also done through a PowerShell windowgem 'googleauth', '~> 1.11'
and gem 'google-cloud-vision'
(and of course all their dependencies). I will try the downgrade at next opportunity and report back!As a bit of further info re: all other pieces of the auth chain working, I have been working around this by not using the gem features and instead doing direct https calls to the Google Cloud Vision API successfully and seeing it tracked on Cloud Console. So all the auth info seems to be correct, fwiw.
I've looked high and low and tried overriding the Google::Cloud::Vision module to inject debug info, but no matter what I do the app server crashes as soon as I try to instantiate a vision client with the line
Google::Cloud::Vision.image_annotator
.I am at a loss as to why this runs fine, connects to the cloud API and outputs as expected in a standalone script, but the same code fails with no exceptions, no logging, nothing but an abrupt server crash in a Rails controller.
For auth, I am using a straightforward service key in a .json file just to get a basic API call to analyze an image successfully.
I've also tried enabling GCV logging per the instructions at https://cloud.google.com/ruby/docs/reference/google-cloud-vision-v1/latest and that did nothing that I could see. If anyone has any suggestions or ideas to workaround or get at further ways to debug this, I'd love to hear them as I'm at a hard block on this now. What am I missing?
Environment details
Steps to reproduce
vision_client = Google::Cloud::Vision.image_annotator
.Code examples
Standalone Ruby script (running this from console via "ruby debug_vision.rb" works and outputs two results as expected):
When running via Rails controller, the credentials are set via an initializer when the server starts:
Rails controller code (this method verifies credentials are correct and that a file is uploaded, but creating the image_annotator client object crashes the server):
Backtrace
None available, just a hard stop crash of the app server.
More Details
I did somewhat successfully override the Google Cloud Vision module to inject some more debugging, which further revealed it's crashing on this line in
def self.image_annotator
:result = service_module.const_get(:Client).new(&block)
This is the full override code (just copied the original source and added a debug line in between each op):
The logging output of this overridden version looks like this when called from the DebugController#moderate action: