erosb / json-sKema

JSON Schema Validator for the JVM, implements draft2020-12
MIT License
49 stars 8 forks source link

kotlin.NotImplementedError #69

Closed hguercan closed 1 month ago

hguercan commented 7 months ago

Hello,

I am receiving for one event validation following error

kotlin.NotImplementedError: An operation is not implemented: something went wrong: com.github.erosb.jsonsKema.MarkableJsonObject@13b61e54 vs { "feature": "some-val", "element": "some-val", "action": "some-val" }

at com.github.erosb.jsonsKema.AggregatingValidationFailure.join$json_sKema(ValidationFailure.kt:67) ~[json-sKema-0.13.0.jar:na]
at com.github.erosb.jsonsKema.DefaultValidator.accumulate(Validator.kt:711) ~[json-sKema-0.13.0.jar:na]
at com.github.erosb.jsonsKema.DefaultValidator.accumulate(Validator.kt:156) ~[json-sKema-0.13.0.jar:na]
at com.github.erosb.jsonsKema.SchemaVisitor.visitCompositeSchema(SchemaVisitor.kt:71) ~[json-sKema-0.13.0.jar:na]
at com.github.erosb.jsonsKema.DefaultValidator.access$visitCompositeSchema$s680550253(Validator.kt:156) ~[json-sKema-0.13.0.jar:na]
at com.github.erosb.jsonsKema.DefaultValidator$visitCompositeSchema$2.invoke(Validator.kt:259) ~[json-sKema-0.13.0.jar:na]
at com.github.erosb.jsonsKema.DefaultValidator$visitCompositeSchema$2.invoke(Validator.kt:258) ~[json-sKema-0.13.0.jar:na]
at com.github.erosb.jsonsKema.DefaultValidator.withOtherInstance(Validator.kt:352) ~[json-sKema-0.13.0.jar:na]
at com.github.erosb.jsonsKema.DefaultValidator.visitCompositeSchema(Validator.kt:258) ~[json-sKema-0.13.0.jar:na]
at com.github.erosb.jsonsKema.DefaultValidator.visitCompositeSchema(Validator.kt:156) ~[json-sKema-0.13.0.jar:na]
at com.github.erosb.jsonsKema.SchemaVisitor.internallyVisitCompositeSchema$json_sKema(SchemaVisitor.kt:55) ~[json-sKema-0.13.0.jar:na]
at com.github.erosb.jsonsKema.CompositeSchema.accept(Schema.kt:26) ~[json-sKema-0.13.0.jar:na]
at com.github.erosb.jsonsKema.DefaultValidator.validate(Validator.kt:249) ~[json-sKema-0.13.0.jar:na]
at com.bonial.tracking.trackingpolicing.service.SchemaValidator.validate(SchemaValidator.java:79) ~[classes/:na]
--> rest i cutted 

Tried to debug through the code and I relly cant find the issue. Using Java 11, json sKema 0.13.0 and also set the kotlin version to 1.9 in my pom.

Is there anything I can do?

hguercan commented 7 months ago

Probably I found the cause:

My event / schema has the name ui_interaction and there is one property called ui_interaction_details. When the json comes with that property the above error occurs. If i remove it, the library works as usual/expected.

erosb commented 7 months ago

Hello Hasan, can you please share

Thank you

hguercan commented 7 months ago

Dear Bence,

Due to sensitive data I cant share it in the first place. For now I needed to solve it very fast but once I find the time I will prepare a dummy dataset to reproduce that error so I can contribute also to improve the library.

However my best guess is: if the parent schema id is a substring of a reference schema id and there are validation errors then this error occurs.

Thanks for your great work so far. Best Hasan

erosb commented 7 months ago

Thank you @hguercan , I appreciate if you spend time on providing a proper reproducer. I couldn't reproduce this so far, but if this problem happens, it can reveal a deep design issue in the validation, so I'm looking forward fixing this.

erosb commented 1 month ago

This should now be resolved in release 0.17.0, please LMK if you still face this issue.