Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-2172

Improve error reporting when nil and empty string are given to URI#get

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.12.0.rc0
    • Affects Version/s: None
    • Component/s: Public API
    • None
    • Fully Compatible

      Currently if an empty string is given to the client, error reporting is not great:

      Mongo:irb(main):001:0> Mongo::Client.new('')
      Traceback (most recent call last):
              7: from /home/me/.rbenv/versions/2.7/bin/irb:23:in `<main>'
              6: from /home/me/.rbenv/versions/2.7/bin/irb:23:in `load'
              5: from /home/me/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/irb-1.2.1/exe/irb:11:in `<top (required)>'
              4: from (irb):1
              3: from (irb):1:in `new'
              2: from /home/me/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/mongo-2.11.3/lib/mongo/client.rb:379:in `initialize'
              1: from /home/me/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/mongo-2.11.3/lib/mongo/uri.rb:229:in `get'
      Mongo::Error::InvalidURI (Bad URI: )
      Invalid scheme ''. Scheme must be 'mongodb' or 'mongodb+srv'
      Please see the following URL for more information: http://docs.mongodb.org/manual/reference/connection-string/
      

      The error message can explicitly state that the empty string is not a valid URI. Same for nil input.

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: