Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing Azure deployed Elastic Cloud cloud_id into Elasticsearch::Client.new resolves to malformed host URL #1494

Closed
EllaBellaStella opened this issue Sep 15, 2021 · 1 comment

Comments

@EllaBellaStella
Copy link

From my Gemfile.lock:

    elasticsearch (7.5.0)
      elasticsearch-api (= 7.5.0)
      elasticsearch-transport (= 7.5.0)
    elasticsearch-api (7.5.0)
      multi_json
    elasticsearch-transport (7.5.0)
      faraday (>= 0.14, < 1)
      multi_json

As title indicates, we have Elasticsearch cluster on Elastic Cloud with both AWS and Azure providers. When the cloud_id is passed into client creation as such Elasticsearch::Client.new(cloud_id: ...) this is the resulting error:

        18: from /Users/yuchunlai/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/elasticsearch-transport-7.5.0/lib/elasticsearch/transport.rb:32:in `new'
       17: from /Users/yuchunlai/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/elasticsearch-transport-7.5.0/lib/elasticsearch/transport.rb:32:in `new'
       16: from /Users/yuchunlai/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/elasticsearch-transport-7.5.0/lib/elasticsearch/transport/client.rb:136:in `initialize'
       15: from /Users/yuchunlai/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/elasticsearch-transport-7.5.0/lib/elasticsearch/transport/client.rb:136:in `new'
       14: from /Users/yuchunlai/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/elasticsearch-transport-7.5.0/lib/elasticsearch/transport/transport/base.rb:47:in `initialize'
       13: from /Users/yuchunlai/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/elasticsearch-transport-7.5.0/lib/elasticsearch/transport/transport/base.rb:136:in `__build_connections'
       12: from /Users/yuchunlai/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/elasticsearch-transport-7.5.0/lib/elasticsearch/transport/transport/base.rb:136:in `map'
       11: from /Users/yuchunlai/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/elasticsearch-transport-7.5.0/lib/elasticsearch/transport/transport/base.rb:144:in `block in __build_connections'
       10: from /Users/yuchunlai/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/elasticsearch-transport-7.5.0/lib/elasticsearch/transport/transport/http/faraday.rb:41:in `__build_connection'
        9: from /Users/yuchunlai/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/faraday-0.17.4/lib/faraday.rb:69:in `new'
        8: from /Users/yuchunlai/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/faraday-0.17.4/lib/faraday.rb:69:in `new'
        7: from /Users/yuchunlai/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/faraday-0.17.4/lib/faraday/connection.rb:80:in `initialize'
        6: from /Users/yuchunlai/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/faraday-0.17.4/lib/faraday/connection.rb:315:in `url_prefix='
        5: from /Users/yuchunlai/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/faraday-0.17.4/lib/faraday/utils.rb:275:in `URI'
        4: from /Users/yuchunlai/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/faraday-0.17.4/lib/faraday/utils.rb:275:in `call'
        3: from /Users/yuchunlai/.rbenv/versions/2.7.1/lib/ruby/2.7.0/uri/common.rb:737:in `URI'
        2: from /Users/yuchunlai/.rbenv/versions/2.7.1/lib/ruby/2.7.0/uri/common.rb:234:in `parse'
        1: from /Users/yuchunlai/.rbenv/versions/2.7.1/lib/ruby/2.7.0/uri/rfc3986_parser.rb:73:in `parse'
/Users/yuchunlai/.rbenv/versions/2.7.1/lib/ruby/2.7.0/uri/rfc3986_parser.rb:67:in `split': bad URI(is not URI?): "https://************.southeastasia.azure.elastic-cloud.com:9243:9243" (URI::InvalidURIError)

Note the URL in the exception has a malformed part where the port number is appended twice. This issue does not arise when I attempt to create a client to connect to our Elastic Cloud AWS cluster.

@EllaBellaStella
Copy link
Author

Very sorry just noticed this was already reported in #1081

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant