Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
KeithGrant opened this issue Oct 14, 2024 · 1 comment

Comments

@KeithGrant
Copy link

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
Copy link

mayndi15 commented Oct 14, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants