jsonschema: panic in LazyRefValidator::lazy_compile with jsonschema 0.21

With jsonschema 0.21, I get a panic out of jsonschema which is hard to debug because of missing detail information:

panicked at .../index.crates.io-6f17d22bba15001f/jsonschema-0.21.0/src/keywords/ref_.rs:103:61:
Invalid schema: ValidationError { instance: Null, kind: Referencing(InvalidUri(Resolve(ResolveError(InvalidBase)))), instance_path: JsonPointer([]), schema_path: JsonPointer([]) }

The schemas in question are relatively reference heavy, I can try to pinpoint it more closely but wanted to report it already.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 25 (25 by maintainers)

Most upvoted comments

Sorry for the delay, I am going to make a new release with the current changes (as there are quite a lot of things already) and will follow up a bit later next week with fixes on the issues we’ve discussed here. Right now I don’t have much time to dive into resolving to implement a proper fix.

Not sure why that would be misleading? Isn’t it an error coming directly out of fluent_uri::UriRef::resolve_against and happens because the base has a fragment defined?

Oh, you’re right. Now I re-read it and it makes sense, as with that typo it becomes a URI with a fragment. My intention was to find a way to make the error more connected with what is defined in the schema, so there is something actionable in the message

Thanks, that would help me a lot! I merged a change for better URI-related errors and will take a look at the issue soon

hi @jrudolph

I believe that the issue is in the $id value, in the original example it is a JSON pointer, but for such cases, internally a fake URI base is used, so it should be fine (I’ve added a test with a minimized version of your schema).

After finishing with drafts support I plan to address error messages and there will be much more context for such cases, which will also pinpoint the exact error location & will have a more descriptive message.

However, maybe some immediate patches to this specific area of URIs will help, I’ll take a look (maybe just adding the input values to the error message will help with debugging)

Thanks for this useful library 😉