When connecting to the emulator, credentials is set to the symbol :this_channel_is_insecure, which fails to pass the config validation:
config_attr :credentials, nil do |value|
allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
allowed.any? { |klass| klass === value }
end
console
$ gcloud beta emulators pubsub start
console
$ GOOGLE_CLOUD_PROJECT=foo \
PUBSUB_EMULATOR_HOST=localhost:8085 \
ruby -r 'google/cloud/pubsub' -e 'Google::Cloud::PubSub.new.create_topic("bar")'
Traceback (most recent call last):
7: from -e:1:in `<main>'
6: from ~/.gem/ruby/2.6.6/gems/google-cloud-pubsub-2.0.0/lib/google/cloud/pubsub/project.rb:202:in `create_topic'
5: from ~/.gem/ruby/2.6.6/gems/google-cloud-pubsub-2.0.0/lib/google/cloud/pubsub/service.rb:121:in `create_topic'
4: from ~/.gem/ruby/2.6.6/gems/google-cloud-pubsub-2.0.0/lib/google/cloud/pubsub/service.rb:65:in `publisher'
3: from ~/.gem/ruby/2.6.6/gems/google-cloud-pubsub-2.0.0/lib/google/cloud/pubsub/service.rb:65:in `new'
2: from ~/.gem/ruby/2.6.6/gems/google-cloud-pubsub-v1-0.1.1/lib/google/cloud/pubsub/v1/publisher/client.rb:198:in `initialize'
1: from ~/.gem/ruby/2.6.6/gems/google-cloud-pubsub-2.0.0/lib/google/cloud/pubsub/service.rb:66:in `block in publisher'
~/.gem/ruby/2.6.6/gems/gapic-common-0.3.3/lib/gapic/config.rb:94:in `block in create_setter': ArgumentError (ArgumentError)
@haines Thank you VERY MUCH for reporting this bug. I reproduced it, and fixed it in my local environment:
google-cloud-pubsub-v1 % git diff
diff --git a/google-cloud-pubsub-v1/lib/google/cloud/pubsub/v1/publisher/client.rb b/google-cloud-pubsub-v1/lib/google/cloud/pubsub/v1/publisher/client.rb
index aa2caadd33..aa232fab26 100644
--- a/google-cloud-pubsub-v1/lib/google/cloud/pubsub/v1/publisher/client.rb
+++ b/google-cloud-pubsub-v1/lib/google/cloud/pubsub/v1/publisher/client.rb
@@ -961,7 +961,7 @@ module Google
config_attr :endpoint, "pubsub.googleapis.com", ::String
config_attr :credentials, nil do |value|
- allowed = [::String, ::Hash, ::Proc, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
+ allowed = [::String, ::Hash, ::Proc, ::Symbol, ::Google::Auth::Credentials, ::Signet::OAuth2::Client, nil]
allowed += [::GRPC::Core::Channel, ::GRPC::Core::ChannelCredentials] if defined? ::GRPC
allowed.any? { |klass| klass === value }
end
gapic-generator-ruby % git diff
diff --git a/gapic-common/lib/gapic/grpc/service_stub.rb b/gapic-common/lib/gapic/grpc/service_stub.rb
index 91dcc267..61b4704d 100644
--- a/gapic-common/lib/gapic/grpc/service_stub.rb
+++ b/gapic-common/lib/gapic/grpc/service_stub.rb
@@ -61,7 +61,7 @@ module Gapic
@grpc_stub = if credentials.is_a? GRPC::Core::Channel
grpc_stub_class.new endpoint, nil, channel_override: credentials,
interceptors: interceptors
- elsif credentials.is_a? GRPC::Core::ChannelCredentials
+ elsif credentials.is_a?(GRPC::Core::ChannelCredentials) || credentials.is_a?(Symbol)
grpc_stub_class.new endpoint, credentials, channel_args: channel_args,
interceptors: interceptors
else
Because google-cloud-pubsub-v1 is a generated client, publishing the fix will require changes in gapic-generator-ruby. I'll post here when the fix has been released.
@haines This issue was fixed with gapic-common v0.3.4 and google-cloud-pubsub-v1 v0.1.2.
Thank you @dazuma for your incredibly quick work on googleapis/gapic-generator-ruby#504 !!!
Thanks for the quick resolution @quartzmo @dazuma! We've now successfully upgraded to google-cloud-pubsub 2.0.0 馃殌
We've now successfully upgraded to google-cloud-pubsub 2.0.0
@haines Great! Thanks for uncovering this issue quickly!