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

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.12.0.rc0
    • Component/s: Public API
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible

      Description

      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.

        Attachments

          Activity

            People

            Assignee:
            oleg.pudeyev Oleg Pudeyev
            Reporter:
            oleg.pudeyev Oleg Pudeyev
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: