PerlDancer / PerlDancer/Dancer2
deserializer error(HTTP Request).
Nobody has claimed this yet.
- Dominant language
- Perl
- Stars
- 604
- Forks
- 288
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 5
Description
I am getting the following error message for
Failed to deserialize content: Class::XSAccessor: invalid instance method invocant: no hash ref supplied at /usr/local/share/perl/5.22.1/Dancer2/Core/Role/Serializer.pm line 71. in /usr/local/share/perl/5.22.1/Dancer2/Core/Request.pm l. 206
I tried inserting a print statement in Request.pm to see the content of the body parameter passed in line 207 as follows
use Data::Dumper;
print Dumper $body;
print Dumper $serializer;
my $data = $serializer->deserialize($body);
return if !defined $data;
These two print statements resulted in the following log messages
$VAR1 = '{"item":{"name":"uart","type":"test"}}';
$VAR1 = bless( {
'content_type' => 'text/html',
'log_cb' => sub { "DUMMY" },
'hooks' => {
'engine.serializer.before' => [],
'engine.serializer.after' => []
},
'config' => {}
}, 'Dancer2::Serializer::Mutable' );
The complete HTTP response was as follows
Note the content type above is 'text/html' instead of 'application/json' which was passed to Dancer2.
bless( {
# '_content' => 'Internal Server Error
#
# Bad Content-Length: maybe client disconnect? (38 bytes remaining) at /usr/local/share/perl/5.22.1/Plack/Request.pm line 260.
# ',
# '_msg' => 'Internal Server Error',
# '_rc' => 500,
# '_headers' => bless( {
# 'content-type' => 'text/plain'
# }, 'HTTP::Headers' ),
# '_request' => bless( {
# '_content' => '{"item":{"name":"uart","type":"test"}}',
# '_method' => 'POST',
# '_uri' => bless( do{\(my $o = 'http://localhost/api/prjEdit/Project.json')}, 'URI::http' ),
# '_headers' => bless( {
# 'content-type' => 'application/json',
# 'content-length' => 38
# }, 'HTTP::Headers' )
# }, 'HTTP::Request' )
# }, 'HTTP::Response' );
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the POST request described in the issue, then read Dancer2/Core/Request.pm around line 206 and Dancer2/Core/Role/Serializer.pm line 71. Compare the request content type, selected serializer, and deserialization error; done means the reported request no longer fails and the behavior is covered by an appropriate regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- perl
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100