Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A resource which does not define content_types_provided() will blow up on request #33

Open
autarch opened this issue Jul 5, 2015 · 0 comments

Comments

@autarch
Copy link
Collaborator

autarch commented Jul 5, 2015

Here's an example stack trace:

Can't use an undefined value as an ARRAY reference at /home/autarch/.perlbrew/libs/perl-5.22.0@dev/lib/perl5/HTTP/Headers/ActionPack/Core/BaseHeaderType.pm line 38.
    HTTP::Headers::ActionPack::Core::BaseHeaderType::new_from_string("HTTP::Headers::ActionPack::MediaType", undef) called at /home/autarch/.perlbrew/libs/perl-5.22.0@dev/lib/perl5/HTTP/Headers/ActionPack.pm line 87
    HTTP::Headers::ActionPack::create(HTTP::Headers::ActionPack=HASH(0x14c13e0), "MediaType") called at /home/autarch/projects/webmachine-perl/lib/Web/Machine/Util.pm line 32
    Web::Machine::Util::create_header("MediaType") called at /home/autarch/projects/webmachine-perl/lib/Web/Machine/FSM/States.pm line 235
    Web::Machine::FSM::States::c3(My::Resource::Test701=HASH(0x16d9428), Plack::Request=HASH(0x111e860), Plack::Response=HASH(0x161d358), HASH(0x18b1040)) called at /home/autarch/projects/webmachine-perl/lib/Web/Machine/FSM.pm line 62
    Web::Machine::FSM::try {...} () called at /home/autarch/.perlbrew/libs/perl-5.22.0@dev/lib/perl5/Try/Tiny.pm line 81
    eval {...} called at /home/autarch/.perlbrew/libs/perl-5.22.0@dev/lib/perl5/Try/Tiny.pm line 72
    Try::Tiny::try(CODE(0x18b1058), Try::Tiny::Catch=REF(0x16e9f60)) called at /home/autarch/projects/webmachine-perl/lib/Web/Machine/FSM.pm line 129
    Web::Machine::FSM::run(Web::Machine::FSM=HASH(0x1857750), My::Resource::Test701=HASH(0x16d9428)) called at /home/autarch/projects/webmachine-perl/lib/Web/Machine.pm line 93
    Web::Machine::call(Web::Machine=HASH(0xbe26b0), HASH(0x161d400)) called at /home/autarch/.perlbrew/libs/perl-5.22.0@dev/lib/perl5/Plack/Component.pm line 50
    Plack::Component::__ANON__[/home/autarch/.perlbrew/libs/perl-5.22.0@dev/lib/perl5/Plack/Component.pm:50](HASH(0x161d400)) called at /home/autarch/.perlbrew/libs/perl-5.22.0@dev/lib/perl5/Plack/Test/MockHTTP.pm line 24
    Plack::Test::MockHTTP::try {...} () called at /home/autarch/.perlbrew/libs/perl-5.22.0@dev/lib/perl5/Try/Tiny.pm line 79
    eval {...} called at /home/autarch/.perlbrew/libs/perl-5.22.0@dev/lib/perl5/Try/Tiny.pm line 72
    Try::Tiny::try(CODE(0x1695738), Try::Tiny::Catch=REF(0x1122f50)) called at /home/autarch/.perlbrew/libs/perl-5.22.0@dev/lib/perl5/Plack/Test/MockHTTP.pm line 27
    Plack::Test::MockHTTP::request(Plack::Test::MockHTTP=HASH(0x180c218), HTTP::Request=HASH(0x180c188)) called at /home/autarch/.perlbrew/libs/perl-5.22.0@dev/lib/perl5/Plack/Test.pm line 38
    Plack::Test::__ANON__(HTTP::Request=HASH(0x180c188)) called at t/701-content-type-is-actionpack.t line 52
    main::__ANON__[t/701-content-type-is-actionpack.t:53](CODE(0x180c230)) called at /home/autarch/.perlbrew/libs/perl-5.22.0@dev/lib/perl5/Plack/Test.pm line 38
    Plack::Test::test_psgi("app", CODE(0xbe2758), "client", CODE(0x180bb70)) called at t/701-content-type-is-actionpack.t line 54

The problem is that the code assumes that the resource will define at least one content type but doesn't check to make sure this is true.

@stevan - any thoughts on what we should do? At the very least we should provide a better error message, but I'm wondering if it might be better to try to work around this. Someone could create a resource class that manually sets the Content-Type header later in the response cycle, for example.

@autarch autarch changed the title A resource which does not define known_content_type() will blow up on request A resource which does not define content_types_provided() will blow up on request Jul 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant