Skip to content

No DB settings for database #84

@BTrey

Description

@BTrey

Using YARBAC with Dancer2 and Database. This has been working but abruptly stopped working yesterday. Immediately prior to it stopping working, I installed Dancer2::Serializer::JSON. Not sure that was the cause of the issue but I thought I'd mention it in case it's relevant. I used git to restore my app to a previous version which was working fine, and it continues to fail. The error I'm getting on the web page is a 500: Can't call method "quick_select" on an undefined value at /usr/local/share/perl/5.14.2/Dancer2/Plugin/Auth/YARBAC/Provider/Database.pm line 108.

The call stack is:

main in -e l. 0
main in -e l. 0
Plack::Handler::Apache2 in /usr/local/share/perl/5.14.2/Plack/Handler/Apache2.pm l. 126
Plack::Handler::Apache2 in /usr/local/share/perl/5.14.2/Plack/Handler/Apache2.pm l. 87
Plack::Component in /usr/local/share/perl/5.14.2/Plack/Component.pm l. 50
Plack::Middleware::Head in /usr/local/share/perl/5.14.2/Plack/Middleware/Head.pm l. 9
Plack::Component in /usr/local/share/perl/5.14.2/Plack/Component.pm l. 50
Plack::Middleware::Static in /usr/local/share/perl/5.14.2/Plack/Middleware/Static.pm l. 18
Plack::Component in /usr/local/share/perl/5.14.2/Plack/Component.pm l. 50
Plack::Middleware::FixMissingBodyInRedirect in /usr/local/share/perl/5.14.2/Plack/Middleware/FixMissingBodyInRedirect.pm l. 50
Dancer2::Core::App in /usr/local/share/perl/5.14.2/Dancer2/Core/App.pm l. 1300
Dancer2::Core::App in /usr/local/share/perl/5.14.2/Dancer2/Core/App.pm l. 1298
Dancer2::Core::App in /usr/local/share/perl/5.14.2/Dancer2/Core/App.pm l. 1379
Return::MultiLevel in /usr/local/share/perl/5.14.2/Return/MultiLevel.pm l. 97
Return::MultiLevel in /usr/local/share/perl/5.14.2/Return/MultiLevel.pm l. 61
Dancer2::Core::App in /usr/local/share/perl/5.14.2/Dancer2/Core/App.pm l. 1378
Dancer2::Core::App in /usr/local/share/perl/5.14.2/Dancer2/Core/App.pm l. 1489
Dancer2::Core::App in /usr/local/share/perl/5.14.2/Dancer2/Core/App.pm l. 1522
Dancer2::Core::Error in /usr/local/share/perl/5.14.2/Dancer2/Core/Error.pm l. 303
Method::Generate::Accessor in (eval 652) l. 18
Dancer2::Core::Error in /usr/local/share/perl/5.14.2/Dancer2/Core/Error.pm l. 290
Dancer2::Core::Error in /usr/local/share/perl/5.14.2/Dancer2/Core/Error.pm l. 111
Dancer2::Core::Error in /usr/local/share/perl/5.14.2/Dancer2/Core/Error.pm l. 160
Dancer2::Core::Error in /usr/local/share/perl/5.14.2/Dancer2/Core/Error.pm l. 386

Checking the Apache log, however, I find:

[Dancer2::Plugin::Auth::YARBAC::Provider::Database:31005] error @2016-06-06 08:21:31> No DB settings for sonic in /usr/local/share/perl/5.14.2/Dancer2/Core/App.pm l. 836

That error actually appears to come from Dancer/Plugin/Database/Core.pm, sub database. In that sub, _get_settings($arg, $settings, $logger) is failing. I added a couple of quick logging lines to _get_settings and I'm seeing:

[Dancer2::Plugin::Auth::YARBAC::Provider::Database:31005] error @2016-06-06 08:21:31> $settings->{connections} connections does not exist in /usr/local/share/perl/5.14.2/Dancer2/Core/App.pm l. 836
[Dancer2::Plugin::Auth::YARBAC::Provider::Database:31005] error @2016-06-06 08:21:31> $settings is $VAR1 = {
'charset' => 'utf-8'
}; in /usr/local/share/perl/5.14.2/Dancer2/Core/App.pm l. 836

However, from the 500 error web page, I see this:

Settings
appdir => '/var/www/sonic/',
apphandler => 'PSGI',
appname => 'SONIC',
behind_proxy => 0,
charset => 'utf-8',
content_type => 'text/html',
engines => {
  logger => {
    File => {
      file_name => 'sonic.log',
      log_dir => '/var/log/sonic'
    }
  },
  session => {
    Cookie => {
      default_duration => 10800,
      secret_key => 'Hidden (looks potentially sensitive)'
    }
  },
  template => {
    template_toolkit => {
      end_tag => '%>',
      start_tag => '<%'
    }
  }
},
environment => 'development',
host => '0.0.0.0',
layout => 'main',
log => 'debug',
logger => 'file',
no_server_tokens => 0,
plugins => {
  Ajax => {
    content_type => 'application/json'
  },
  'Auth::YARBAC' => {
    after_login => '/',
    after_logout => '/',
    login_denied => '/',
    no_login_required => '^/login|^/about|^/adduser|^/$',
    realms => {
      dexter => {
        db_connection_name => 'sonic',
        provider => 'Database'
      /
    }
  },
  Database => {
    connections => {
      dexter => {
        database => 'dexter',
        dbi_params => {
          AutoCommit => 1,
          RaiseError => 1
        },
        driver => 'mysql',
        host => 'localhost',
        log_queries => 1,
        on_connect_do => [
          'SET CHARACTER SET \'utf8\'',
          'SET SQL_MODE=\'TRADITIONAL\''
        ],
        password => 'Hidden (looks potentially sensitive)',
        port => 3306,
        username => 'dexter'
      },
      sonic => {
        database => 'sonic',
        dbi_params => {
          AutoCommit => 1,
          RaiseError => 1
        },
        driver => 'mysql',
        host => 'localhost',
        log_queries => 1,
        on_connect_do => [
          'SET CHARACTER SET \'utf8\'',
          'SET SQL_MODE=\'TRADITIONAL\''
        ],
        password => 'Hidden (looks potentially sensitive)',
        port => 3306,
        username => 'dexter'
      }
    }
  }
},
port => '3000',
public_dir => '/var/www/sonic/public',
route_handlers => [
  [
    'AutoPage',
    1
  ]
],
session => 'Cookie',
show_errors => 1,
startup_info => 1,
static_handler => 1,
template => 'template_toolkit',
traces => 0,
views => '/var/www/sonic/views',
warnings => 1


Note: Values of 3 sensitive-looking keys hidden

So it appears as though the settings are being correctly read from my .yml file. I'm far from an expert Perl developer, so perhaps I just have something screwed up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions