-
-
Notifications
You must be signed in to change notification settings - Fork 624
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
Schema for defer_call
contains invalid JSON Schema, causing some schema validators to fail
#1474
Comments
Hi @sirosen. Thanks for the report. This is actually a duplicate of #1471, reported just a few days before, but since there is a bit more detail here, I'll keep this issue open and close the other one. Our schema is definitely in need of a bit of TLC. It started as a 3rd-party contribution to the schemastore repo and was brought in-house not too long ago. I can't speak for @andreynering, but besides the small bits of work I've done to maintain it here, I'm not hugely experienced with the details of JSON Schema, so any recommendations/advice you have for cleaning it up are very welcome - PRs are also very welcome.
cmds:
- defer: echo "foo" or cmds:
- defer: { task: "print-foo" } so I believe your assertion that it should in fact be
This was originally intended for versioning yes. However, we are not currently maintaining any other versions in the schema and we've actually just dropped support for v2 schemas (good timing), so I'm personally happy to accept a PR that drops this intermediate key. We can always revisit this if we need to support multiple versions again in the future.
This is really useful info. I have a couple of questions if you don't mind:
Please feel free. If you have any Task-specific questions, feel free to reach out here on over on our Discord. |
Thanks for the reply! Let me work up a (single) PR with the improvements in the next day or two and we can take it from there. And sorry for not seeing the earlier issue!
I'll do my best! As a small caveat, I wouldn't consider myself an expert in JSON Schema -- maybe an "intermediate user". My tool is a frontend for an implementation by a true expert. 😄
There isn't strong consensus about this, as there are pros and cons. I would advise keeping it at draft 7 at least until you have more time to consider these notes. But probably I would just stick with draft 7 until you have a reason to use something newer.
It's all a rolling version situation and everyone is left on their own to decide what to support. I generally think the new drafts are nicer to use, but you'll need to weigh that against what clients you would drop by using the 2019 draft. In my own job/life I haven't had to think very hard about this, so it's possible that there are significant benefits to the newer drafts that I don't know about.
I don't have a template or GitHub Action/Workflow, but since it's a CLI app I can provide a quick primer on installing it and then I could offer up a PR or draft PR to add it.
First, for local usage, if you care: long-winded thing about how to install a Python CLI applicationThe main distribution channel is pypi.org (the Python Package Index), so if you have Python background, you can pick it up with If you aren't a Python developer, I'd very, very strongly recommend using Python currently/still has a pretty weak story around building single-file binaries, and I haven't been able to invest in trying some of the build tools which address this. So for now, Second, for use in GitHub Actions: GitHub provides actions for setting up python environments, and I believe that the latest worker images ship with pipx install check-jsonschema
check-jsonschema --check-metaschema foo/bar/schema.json but I haven't tested this out yet. Let me try and see what the worker images provide (I'll do this soon). |
This was encountered and reported against
check-jsonschema
(a JSON Schema CLI): python-jsonschema/check-jsonschema#376That bug report covers two issues:
I'm pursuing (2) independently. Regarding (1), here's the malformed JSON Schema data:
task/docs/static/schema.json
Lines 351 to 353 in dc3cf1c
"string"
is not a valid subschema. Possibly this was meant to be{"type": "string"}
(?) but it's not obvious.Aside: Fixing the structure of
definitions
The current schema has all
definitions
nested under an intermediate key, i.e.definitions/3/foo
rather thandefinitions/foo
. That weakens the ability of downstream validation of thedefinitions
section of the schema.definitions
is defined under the Draft 7 metaschema as an object whose values are all, themselves, valid schemas.The current structure of the schema means that this is validating
#/definitions/3
rather than#/definitions/defer_call
(which would be much more useful).It would be nice to move all of the definitions up one level so that metaschema validation can catch issues like this.
(Shameless plug:
check-jsonschema --check-metaschema schema.json
can do this for you. 🙂 )Under the latest draft definition of $defs, this kind of structure is more clearly spelled out, using "MUST"s to clarify that a schema which doesn't follow this structure is invalid. Under the Draft 7 spec, I think it's pretty clear that this was the intent based on the metaschema, but it wasn't called out explicitly.
I have no direct experience with
task
, so I might not be the right person to modify the schema appropriately.But I'm happy to submit one or two PRs to
"string"
indefer_call
3
fromdefinitions
nesting (If this is versioning, we could rename all of the defs to end withv3
, as inenv -> env_v3
)Just let me know how to proceed!
The text was updated successfully, but these errors were encountered: