hnaderi/yaml4s

Backend.parse throws DuplicateKeyException rather than return Either Left

KeithGrant opened this issue · 1 comments

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)

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