taplo icon indicating copy to clipboard operation
taplo copied to clipboard

Duplicate errors reported

Open akbyrd opened this issue 2 years ago • 1 comments

In some cases when a file doesn't validate against the schema duplicate errors are emitted for each key in the table, rather than only the key the failed to validate.

In this image foo and bar are valid keys and additionalProperties is set to false in the schema. baz is not allowed and should therefore be an error. However errors also how up on baz and the first instance of test image

This can get particularly bad when a small error in one location propagate up a large chain of tables. It can lead to hundreds of errors.

I used this schema and file to reproduce

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "properties": {
    "test": {
      "type": "object",
      "properties": {
        "foo": {
          "type": "boolean"
        },
        "bar": {
          "type": "boolean"
        }
      },
      "additionalProperties": false
    }
  }
}
#: schema test.json

test.foo = true
test.bar = true
test.baz = true

akbyrd avatar Dec 12 '23 09:12 akbyrd

I've also been experiencing this. That's pretty old, but I don't think there has ever been an issue for it. So let's use this one to track that issue.

I don't think this will ever get fixed without someone really looking into how Taplo works. Fixing this correctly would probably need some refactoring.

ia0 avatar Dec 12 '23 10:12 ia0