geofffranks / json-api

A perl module to simplify interaction with JSON APIs
Other
6 stars 6 forks source link

Test suite started to fail (withJSON::XS 4.0?) #4

Closed eserte closed 4 years ago

eserte commented 5 years ago

On my smokers I see the following test failures:

#   Failed test 'Invalid object sent for serialization returns undef'
#   at t/core.t line 54.
#          got: '"asdf"'
#     expected: undef

#   Failed test 'Bad encode sets proper errstr'
#   at t/core.t line 55.
#          got: ''
#     expected: 'hash- or arrayref expected (not a simple scalar, use allow_nonref to allow this)'
# Looks like you failed 2 tests of 24.
t/core.t ...... 
Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/24 subtests 

#   Failed test 'Scalar context for /put_invalid_json bails before request'
#   at t/requests.t line 17.
#     Structures begin differing at:
#          $got->{code} = 'success'
#     $expected->{code} = Does not exist

#   Failed test 'List context HTTP Code for /put_invalid_json bails before request should return 500'
#   at t/requests.t line 19.
#          got: '200'
#     expected: '500'

#   Failed test 'List context response for /put_invalid_json bails before request'
#   at t/requests.t line 20.
#     Structures begin differing at:
#          $got->{code} = 'success'
#     $expected->{code} = Does not exist
# Looks like you failed 3 tests of 35.
t/requests.t .. 
Dubious, test returned 3 (wstat 768, 0x300)
Failed 3/35 subtests 

This seems to happen if the newest version of JSON::XS (4.0) is installed.

RoyceTheBiker commented 5 years ago

I am also getting this error.

I cannot confirm that it is related to JSON::XS but I have version 4.02 installed.

RoyceTheBiker commented 5 years ago

My JSON::XS 4.02 came in as a CPAN dependency, possibly from trying to install JSON::API via CPAN as I could not find a package for it.

I removed the JSON::XS 4.02 and installed the vendor package. Now I have version 3.01 and the CPAN install for JSON::API works.

Linux Mint 18.2 Sonya based on Debian Stretch.

dmolik commented 4 years ago

@geofffranks I can take a look at the testsuite, can you add the hacktoberfest label to this bug?

http://www.cpantesters.org/cpan/report/467724f0-bcf3-11e9-87ff-99d510da25b2

dmolik commented 4 years ago

After running ./Build test locally I didn't get an error. crud

dmolik commented 4 years ago

I do have json::xs 3.4 installed though

dmolik commented 4 years ago

Good news! I've upgraded JSON::XS to 4.x and I'm now getting test failures!

dmolik commented 4 years ago

Bad news the errors indicate JSON::XS isn't throwing errors when bad json is given to deserialize. I'll check on the use flags when importing JSON;

tehmoth commented 4 years ago

since JSON::XS 4, allow_nonref is default true, which causes it to no longer throw for "invalid" json. See https://github.com/geofffranks/json-api/pull/6