question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Specify maximum errors

See original GitHub issue

What version of Ajv you are you using?

6.12.3

What problem do you want to solve?

We recently received a CodeQL security vulnerability relating to setting allErrors: true in AJV because this can cause resource exhaustion if a nefarious payload is provided.

It would be ideal to be able to specify a specific upper limit of errors before validation is exited. Otherwise, we have to specify allErrors: false and users have to continually re-submit their payloads because only one errors is returned at a time, which is a poor user experience.

It would be best if we can specify an upper limit (like 1000 errors) so that users can recieve more than one error at a time, and we ensure that a resource exhaustion attack is mitigated based on the available hardware.

What do you think is the correct solution to problem?

Add a new property to Ajv options that specifies the maximum number of errors allowed, and then use that in the validation function to return early once reached.

Will you be able to implement it?

Yes, if I can get some guidance on where this validation takes place.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mguay22commented, Jun 16, 2022

@epoberezkin Ok - appreciate the quick reply.

1reaction
epoberezkincommented, Jun 16, 2022

Re proposed feature - it’s non-trivial, it will affect all code generation, and likely to have a negative performance impact. Let’s keep the issue open and see if there is more interest in this feature, right now it doesn’t seem like a good value tbh.

Assuming API users are developers you can always provide a sandbox server for testing to receive all errors, and you should not really use API to generate user facing errors - for this purpose you can run Ajv (or pre-compiled schemas) client side.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the maximum error? - Quora
It means the website you are trying to reach has a server that isn't working. The only things an end user can do...
Read more >
How to Determine Greatest Possible Error - Study.com
Learn how to determine greatest possible error, and see examples that walk through sample problems step-by-step for you to improve your math knowledge...
Read more >
Differentials: Estimating Maximum Error in Volume - YouTube
We have a magical cube, and we measure its side length to be 2.However, we know our measurement could be inaccurate with max...
Read more >
error-limit
Specifies the maximum number of error-level or fatal-level compiler errors allowed for a file specified on the command line.
Read more >
Margin of Error - an overview | ScienceDirect Topics
The maximum error of estimation, also called the margin of error, is an indicator of the precision of an estimate and is defined...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found