cardinalby / schema-validator-action

JSON Schema validator Action
MIT License
13 stars 2 forks source link

[feature request] More detailed errors #16

Open Bluscream opened 3 weeks ago

Bluscream commented 3 weeks ago

EDIT: Since you seem to be responsive i might just add that as a request; It would be very neat if the error spit out by the action would include (maybe optionally idk):

.

cardinalby commented 3 weeks ago

That's all is possible for sure, but I have no capacity to implement these improvements since

  1. there are some more relevant issues that are still not addressed
  2. JSON schema validation (with all modern features) is quite complicated process, the action just uses the underlying schemasafe lib and it may be that in the future I will have to change the library (I did it once in the past) if it fails to satisfy the standard's requirements. I investigated the existing JS libraries and none of them implements all the features correctly, or are very difficult to use. Because of that I try not to be bound to a particular library (and the way it reports the errors) if possible

But if you have an idea how it can be implemented in a neat way you can prepare a PR

Bluscream commented 3 weeks ago

Isn't atleast the last one possible? It would save me a lot of time waiting for workflow runs :D

https://github.com/Bluscream/AMPTemplates/actions/workflows/validate.yml?query=is%3Afailure

P.S. If you have high standards i'm better off not even attempting at PRing anything :joy:

cardinalby commented 3 weeks ago

I already included allErrors: true option to schemasafe options. It still returns the first error, maybe I'm wrong in a way I use the library, but that's the behaviour I see. If you can find out the reason this option is ignored (and extraFormats as well) I would accept the PR

P.S. The action has some tests that can be run locally and you can debug it

Bluscream commented 3 weeks ago

mhmm, is schemasafe using ajv in the background? Because i literally found the same bug in ajv (that it always throws on unknown format no matter which options are set)

The other thing i think is because it finds the "error" with the continuation is because it finds the error when checking the schema, not the json. so it throws before it even starts validating the json with the schema that it failed to load

no matter how much error catching i do, i can't do shit about it throwing before the schema is "compiled" https://github.com/ammarlakis/action-ajv/pull/3/files#diff-bfe9874d239014961b1ae4e89875a6155667db834a410aaaa2ebe3cf89820556L90

cardinalby commented 3 weeks ago

is schemasafe using ajv in the background?

no I believe

it finds the error when checking the schema, not the json

in this case it's expected at least, in my case schema compiles successfully, the data contains 2 errors (schema violations) and I still see only 1 error in validate.errors