Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-5099

Provide a better error message when loading an empty configuration file

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 7.1.11, 7.2.6, 7.3.3
    • Affects Version/s: None
    • Component/s: None
    • None
    • Minor Change

      When Mongoid is asked to load a configuration file which happens to be empty, it produces a message that references an internal error:

       

      irb(main):018:0> Mongoid.load!("empty.yml")
      Traceback (most recent call last):
             16: from /home/w/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.15/lib/bundler/cli.rb:30:in `dispatch'
             15: from /home/w/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.15/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
             14: from /home/w/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.15/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
             13: from /home/w/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.15/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
             12: from /home/w/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.15/lib/bundler/cli.rb:494:in `exec'
             11: from /home/w/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.15/lib/bundler/cli/exec.rb:28:in `run'
             10: from /home/w/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.15/lib/bundler/cli/exec.rb:63:in `kernel_load'
              9: from /home/w/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/bundler-2.2.15/lib/bundler/cli/exec.rb:63:in `load'
              8: from /home/w/.rbenv/versions/2.7/bin/irb:23:in `<top (required)>'
              7: from /home/w/.rbenv/versions/2.7/bin/irb:23:in `load'
              6: from /home/w/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/irb-1.2.6/exe/irb:11:in `<top (required)>'
              5: from (irb):17
              4: from (irb):18:in `rescue in irb_binding'
              3: from /home/w/.rbenv/versions/2.7.2/lib/ruby/2.7.0/forwardable.rb:235:in `load!'
              2: from /home/w/apps/mongoid/lib/mongoid/config.rb:133:in `load!'
              1: from /home/w/apps/mongoid/lib/mongoid/config/environment.rb:55:in `load_yaml'
      NoMethodError (undefined method `[]' for false:FalseClass)
      
      
      The error message should reflect the error condition (i.e. the configuration file is empty or doesn't contain a configuration for the active environment).
       

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

              Created:
              Updated:
              Resolved: