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

[Feature Request] Expose the real error of the schema inside "contains" #461

Open
EvanZhang008 opened this issue Jul 8, 2022 · 2 comments

Comments

@EvanZhang008
Copy link

EvanZhang008 commented Jul 8, 2022

Currently, the real error message inside contains will get lost. The end error we get is something like "expected at least one array item to match 'contains' schema", and it stops at "contains".

I think exposing the real error of the schema inside "contains" is a valid use case. Are there any technically difficulties and plans of doing this?

@erosb
Copy link
Contributor

erosb commented Jul 12, 2022

Are there any technically difficulties and plans of doing this?

There is no technical difficulty, but there is a security risk. The proper way to address this problem would be including the schema validation failure of every array item (since they may fail for different reasons) to properly justify that no items matched the "contains" schema. If a malicious user submits a large array that produces complex-enough failures during validation, then collecting all failures may cause an OOME. When implementing this library, I tried to be cautious about including arbitrary-sized data (defined by the size of the validated instance) in the validation results.

@EvanZhang008
Copy link
Author

EvanZhang008 commented Jul 12, 2022

Thanks for the explanation, it does make sense.

I think the risk is also existed in other places like keyword items. It seems like a shared responsibility between validator and consumer. It would be nice to have an option to ack the risk and enable this.

Currently, Is there a way for us to enable this feature by passing some arguments? Or maybe ways to bypass this issue? One way I can think of as a consumer is to run validation again on our own for the schema inside the contains.

If not, I am wondering if you have any plans to support this as an optional feature?

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

No branches or pull requests

2 participants