stoplightio / yaml

Useful functions when working with YAML.
Apache License 2.0
13 stars 3 forks source link

fix: more sane errors for unclosed flow collections #52

Closed P0lip closed 3 years ago

P0lip commented 3 years ago

For https://github.com/stoplightio/platform-internal/issues/6014 We could potentially address this in yaml-ast-parser, but IMHO what the parser does is correct. The parser is not to be blamed for trying to accumulate all errors.

The alternative approach I considered was adding some condition here https://github.com/stoplightio/yaml-ast-parser/blob/master/src/loader.ts#L854. I was thinking of something as follows: if, say, comma is missed 5 times, we would just naively assume the flow collection might be possibly never closed correctly and just stop collecting these errors until the loading is able to recover. However as said above, the parser does something incorrectly, so we can just filter them out here.

P0lip commented 3 years ago

I have a question about why we account for this in this repo and not in Spectral.

Spectral consumes the errors produced by this package and its equivalent for JSON (@stoplight/json).

If time permits, would you be able to tell me how this fits into the larger picture?

Sure, perhaps we can sync at some point? Might be easier to go over it on a call.

stoplight-bot commented 3 years ago

:tada: This PR is included in version 4.2.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: