[dancer-users] Route exception: Undef did not pass type constraint "Str"

Gabor Szabo gabor at szabgab.com
Thu Sep 24 15:44:32 BST 2015


On Thu, Sep 24, 2015 at 4:57 PM, Gabor Szabo <gabor at szabgab.com> wrote:

>
> On Thu, Sep 24, 2015 at 4:14 PM, Gabor Szabo <gabor at szabgab.com> wrote:
>
>> While trying to deploy an application I've just encountered this error:
>>
>> error @2015-09-24 09:06:31> Route exception: Undef did not pass type
>> constraint "Str" (in $args->{"name"}) at (eval 663) line 192
>>     "Str" is a subtype of "Value"
>>     "Value" is a subtype of "Defined"
>>     Undef did not pass type constraint "Defined" (in $args->{"name"})
>>     "Defined" is defined as: (defined($_)) in
>> /home/user/perl5.22.0/lib/site_perl/5.22.0/Dancer2/Core/App.pm l. 1276
>>
>> I don't see this on my development machine and so far I have no idea
>> where to look.
>>
>> Before I go down the rabbit hole trying to find the differences and the
>> source of the problem,
>> I wonder if anyone has encountered this.
>>
>> Dancer2 0.162   on both machines:
>> dev using plackup 1.0037
>> prod using Starman 0.4014
>>
>> Dancer2::Plugin::Auth::Extensible 0.401
>>
>> regards
>>    Gabor
>>
>
>
> I tried using plack on the server and it work properly.
> It also seems to work well when I run
>
> plackup -s Starman -p 3000
>
> So it seems this is something related to how I run Starman which is by way
> of this script launched
> from /etc/rc.local
>
>
> #!/home/user/perl5.22.0/bin/perl
> use warnings;
> use strict;
> use Daemon::Control;
>
> use File::Basename qw(dirname);
> use Cwd qw(abs_path);
>
> Daemon::Control->new(
>         {
>                 name      => 'Starman',
>                 lsb_start => '$syslog $remote_fs',
>                 lsb_stop  => '$syslog',
>                 lsb_sdesc => 'Starman Short',
>                 lsb_desc  => 'Starman controls the web sites.',
>                 path      => abs_path($0),
>
>                 program => dirname($^X) . '/starman',
>
>                 program_args => [ '--workers', '5', '--port', '3000',
> '/home/user/work/app/app.psgi' ],
>
>                 pid_file    => '/tmp/starman.pid',
>                 stderr_file => '/tmp/starman.err',
>                 stdout_file => '/tmp/starman.out',
>
>                 fork => 2,
>
>         }
> )->run;
>
>
> Oh and I am using perl 5.22.
>
>
> Gabor
>
>
>
>


OK I found the source of this error.
I have put the mongodb configuration parameters in the
environment/development.yml which worked every time I used plack, but
when I launched Starman directly then it was using a differetn environment
(deployment if I am not mistaken).

The solution was to add

$ENV{DANCER_ENVIRONMENT} = 'production';

to the code launching Starman

and add the appropriate mongodb configuration options to the
environment/production.yml file.


Now I just wonder if Dancer could have provided me with a better error
report?

Gabor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20150924/f02b4234/attachment.html>


More information about the dancer-users mailing list