hnaderi / yaml4s

YAML for Scala, Scala.js and Scala native
http://projects.hnaderi.dev/yaml4s/
Apache License 2.0
4 stars 0 forks source link

Backend.parse throws DuplicateKeyException rather than return Either Left #157

Open KeithGrant opened 1 month ago

KeithGrant commented 1 month ago

YAML had a duplicate key, expected: Left(DuplicateKeyException) actual: thrown DuplicateKeyException

stack trace:

org.snakeyaml.engine.v2.constructor.StandardConstructor.processDuplicateKeys(StandardConstructor.java:90) org.snakeyaml.engine.v2.constructor.StandardConstructor.flattenMapping(StandardConstructor.java:70) dev.hnaderi.yaml4s.snakeyaml.SnakeParser$FlatteningConstructor.flatten(SnakeParser.scala:112) dev.hnaderi.yaml4s.snakeyaml.SnakeParser.yamlToJson(SnakeParser.scala:176) dev.hnaderi.yaml4s.snakeyaml.SnakeParser.parse$$anonfun$1(SnakeParser.scala:36) scala.util.Either.flatMap(Either.scala:360) dev.hnaderi.yaml4s.snakeyaml.SnakeParser.parse(SnakeParser.scala:36) dev.hnaderi.yaml4s.snakeyaml.SnakeParser.parse$(SnakeParser.scala:32) dev.hnaderi.yaml4s.Backend$.parse(Backend.scala:19)

mayndi15 commented 1 month ago

The error occurred due to duplicate keys in the YAML file. Review and remove the duplicates and the code capture the DuplicateKeyException and return it as Left(DuplicateKeyException) instead of throwing it directly if possible send the YAML file for a more detailed review