tobyink / p5-json-schema

1 stars 4 forks source link

JSON::Schema can't validate the core schema against itself #16

Open tobyink opened 3 years ago

tobyink commented 3 years ago

Migrated from rt.cpan.org #125196 (status was 'new')

Requestors:

From faminebadger@googlemail.com on 2018-04-24 12:30:16 :

This transaction appears to have no content

tobyink commented 3 years ago

From faminebadger@googlemail.com on 2018-04-24 12:40:28 :

I got some kind of queue error trying to raise the ticket, and it lost what I typed.

So, here it is:


In trying to validate my own schema against the core schema (http://json-schema.org/draft-07/schema#), I got the following fatal error:

"Not a HASH reference at /home/famine/perl5/lib/perl5/JSON/Schema/Helper.pm line 163."

So I backtracked and tried to validate the core schema against itself (which is correct - the schema defines its $schema property as itself).

This failed in the same way, which is rather disappointing. This means this module doesn't work properly.

A quick bit of debugging shows that the error is thrown by the "addError" sub variable defined in the "checkProp" operation, because "$schema" isn't a hash when iterating the for loop.

Further debug shows me that the original error lost by the error in the addError operation was "Invalid schema/property definition 1", and that the value of both "$value" and "$schema" as passed to checkProp are the same function reference to return 1 (aka a boolean) : "bless( do{(my $o = 1)}, 'JSON::PP::Boolean' );"

I don't have a clue how to fix this, not being at all familiar with this module code, and given it's not particularly written for readability / ease of debug.