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

Upgrade json schema version #13746

Closed
fcollonval opened this issue Jan 10, 2023 · 7 comments
Closed

Upgrade json schema version #13746

fcollonval opened this issue Jan 10, 2023 · 7 comments

Comments

@fcollonval
Copy link
Member

fcollonval commented Jan 10, 2023

Problem

It could be interesting to bump the JSON Schema version used from draft04 to some more recent flavor (last proposal is 2020-12).

The new version needs to be compatible with:

The Python package seems to be the one falling behind in term of standard support.

@fcollonval fcollonval added enhancement status:Needs Triage Applied to new issues that need triage labels Jan 10, 2023
@fcollonval fcollonval added this to the 4.0.0 milestone Jan 10, 2023
@fcollonval fcollonval changed the title Upgrade json-schema Upgrade json schema version Jan 10, 2023
@JasonWeill JasonWeill added maintenance and removed status:Needs Triage Applied to new issues that need triage labels Jan 12, 2023
@bollwyvl
Copy link
Contributor

Python jsonschema

Things look mostly fine here: Draft202012Validator, with the README suggesting a key missing useful thing ($vocabulary) will be supported, presumably at some point within the jsonschema@4.* release cycle.

JS react-json-schema-form

Indeed: I've been waiting with baited breath to get a live rjsf 5, which splits out the ajv dependency, so it can be upgraded. ajv is already a huge dep, so should be moved wholesale to 8, if possible, for lab4.

Getting this hoisted as a shared package would be huge, as well as loading it as lazily as possible, as it is, well, huge.

JS ajv

Of note: even ajv@8 still gets flagged for unsafe-eval, by default, and there's really no way around it for the kinds of dynamic things jupyterlab does (e.g. translation). When addressing this systematically, it likely makes sense to offer a IJSONSchema plugin, such that one could inject a "safe" parser... if it were to exist. It would definitely be slower... even the rust-based one says just go use ajv... and WASM is usually not the best place to go without a sound reason.

@bollwyvl
Copy link
Contributor

rjsf 5 is out 🎉

@bollwyvl
Copy link
Contributor

Buried in updating after 6 months of version drift, the actual work was not that bad upgrading to rjsf5/ajv8. Once I've done some more work (and gotten a 3.x compatible release out of the stable of downstreams), it should be relatively easy to get a PR together to get lab going.

I'm working on cutting the file sizes down... but as the lab ajv and rjsf aren't singletons/exposed, I was paying for it anyway.

However, lowering the bar for extension authors to "ship thoughtful schema, get 🍬" is going to be really good.

Also: holy mackerel, this looks like an excellent thing:

https://ajv.js.org/guide/typescript.html#type-safe-parsers-and-serializers

There are a lot of places where i do a lot of intermediate processing of schema to get to types, but having the ts directly consume and validate the JSON string off the wire seems really powerful for frequently-used message types.

@JasonWeill JasonWeill modified the milestones: 4.0.0, 4.1.0 Feb 1, 2023
@krassowski krassowski modified the milestones: 4.1.0, 4.0.0 Feb 2, 2023
@bollwyvl
Copy link
Contributor

bollwyvl commented Feb 5, 2023

Some notes from the field of #13924:

@bollwyvl
Copy link
Contributor

bollwyvl commented Feb 5, 2023

On custom keywords.

  • we can't yet use ajv strict mode
    • while it is possible to add custom vocabularies...
      • ... we can't even pass that, due to use of the . character in custom plugin schema keywords
        • i don't know, or really care why
      • one approach would be to blanket replace . with : for URN-like constructs, e.g.:
        • jupyter.lab.internationalization
        • jupyter:lab:internationalization

@bollwyvl bollwyvl mentioned this issue Feb 5, 2023
13 tasks
@bollwyvl
Copy link
Contributor

bollwyvl commented Feb 5, 2023

Of note: even if we move the front end to ajv8, eslint still uses ajv6. I don't know what the support window for ajv6 is.

bollwyvl added a commit to bollwyvl/jupyterlab that referenced this issue Feb 8, 2023
bollwyvl added a commit to bollwyvl/jupyterlab that referenced this issue Feb 9, 2023
@JasonWeill JasonWeill modified the milestones: 4.0.0, 4.1.0 Mar 1, 2023
@krassowski krassowski modified the milestones: 4.1.0, 4.0.0 Feb 5, 2024
@krassowski
Copy link
Member

Closing because we migrated to draft07 in 4.0.x cycle:

I believe it would be safer to stay on draft07 for a while, until support for newer versions stabilises, and because the newer versions have breaking changes we may want to wait until JupyterLab 5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants