atlassian / atlassian/better-ajv-errors

Feature request: Filter out 'shadowing' errors, for the humans

Open
#76 4 comments 1 reaction 0 assignees View on GitHub
feature request
Dominant language
JavaScript
Stars
245
Forks
50
PR merge metrics
No merged PRs in 30d

Description

Hi there 👋. Awesome repo you've got here!

We at the [stryker mutation testing](https://stryker-mutator.io) team have been looking into validation with ajv. We've come to the same conclusion, error messages directly from AJV are not really designed for humans. We're thinking of using better-ajv-errors.

However, we're also thinking of filtering out what I call 'shadowing' errors.

A shadowing error is an error that results logically from another error. Some examples:

```js
[
{ // This is a useless error for a human
keyword: 'type',
dataPath: '.mutator',
params: { type: 'string' },
// [...]
},
{ // => This is the most specific error. This is for humans!
keyword: 'required',
dataPath: '.mutator',
params: { missingProperty: 'name' },
// [...]
},
{ // This is a useless error for a human
keyword: 'oneOf',
dataPath: '.mutator',
params: { passingSchemas: null },
[...]
}
]
```

Or:

```js
[
{ // This is a useless error for a human
keyword: 'type',
dataPath: '.logLevel',
params: { type: 'string' },
// [...]
},
{ // => This is the most specific error. This is for humans!
keyword: 'enum',
dataPath: '.logLevel',
params: { allowedValues: ['info', 'warn'] },
// [...]
},
]
```

A first draft of the filtering is created here:

https://github.com/stryker-mutator/stryker/blob/627d2f7e403042845bcece73c838c9447bbf522c/packages/core/src/config/validationErrors.ts#L55-L74

Do you think this filtering is useful for other projects as well? Should it be added to better-ajv-errors? Maybe as an option? Or do you want to keep it separate?

I would be willing to prepare it in a PR if you agree that this is a feature useful for all humans, nut just mutant-killing humans 😉.

Contributor guide

No contributing guide indexed for this repository

Research direction

Review the shadowing-error examples in this issue and the linked Stryker draft at packages/core/src/config/validationErrors.ts#L55-L74. First establish the intended filtering rules and whether they belong in better-ajv-errors or remain separate; done requires an agreed feature scope and option behavior, followed by validation against the shown AJV errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.