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

Parsing of mongoid.yml doesn't respect comments properly

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 6.4.4
    • Component/s: None
    • None

      Lines will be parsed by the templating engine even if they are commented out. The following configuration snippet will lead to parsing errors since the "<%= ... %>" marker will trigger variable substitution:

       

      Configuration: 

       

      test:
        clients:
          default:
            # uri: mongodb://user:password@mongodb.domain.com:27017/<%=  database_name || app_name %>_development

      Log:

       

      rails_1 | NameError: undefined local variable or method `database_name' for main:Object
      rails_1 | (erb):19:in `<main>'
      rails_1 | /home/integration-dashboard/.gem/gems/mongoid-6.4.4/lib/mongoid/config/environment.rb:40:in `load_yaml'
      rails_1 | /home/integration-dashboard/.gem/gems/mongoid-6.4.4/lib/mongoid/config.rb:86:in `load!'
      rails_1 | /home/integration-dashboard/.gem/gems/mongoid-6.4.4/lib/mongoid.rb:104:in `load!'
      rails_1 | /home/integration-dashboard/.gem/gems/mongoid-6.4.4/lib/mongoid/railtie.rb:58:in `block in <class:Railtie>'
      rails_1 | /home/integration-dashboard/.gem/gems/railties-5.2.4.2/lib/rails/initializable.rb:32:in `instance_exec'
      rails_1 | /home/integration-dashboard/.gem/gems/railties-5.2.4.2/lib/rails/initializable.rb:32:in `run'
      rails_1 | /home/integration-dashboard/.gem/gems/railties-5.2.4.2/lib/rails/initializable.rb:61:in `block in run_initializers'
      rails_1 | /home/integration-dashboard/.gem/gems/railties-5.2.4.2/lib/rails/initializable.rb:60:in `run_initializers'
      rails_1 | /home/integration-dashboard/.gem/gems/railties-5.2.4.2/lib/rails/application.rb:361:in `initialize!'
      rails_1 | /opt/integration-dashboard/config/environment.rb:5:in `<top (required)>'

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            arent.groebner@gmail.com Arent Gröbner
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: