psyinfra / onyo

text-based inventory system on top of git
ISC License
3 stars 5 forks source link

DOCS: Error message from duplicate template keys is unclear #436

Open nhjjr opened 8 months ago

nhjjr commented 8 months ago

When a template has duplicate keys the resulting error is both vague (to an Onyo user) and refers to documentation from a dependency.

Template:

---
rating: foo
rating: bar

Output when using onyo new:

ERROR: while constructing a mapping
  in "/home/niels/code/onyo-demo/.onyo/templates/boardgame", line 2, column 1
found duplicate key "rating" with value "foo" (original value: "bar")
  in "/home/niels/code/onyo-demo/.onyo/templates/boardgame", line 3, column 1

To suppress this check see:
    http://yaml.readthedocs.io/en/latest/api.html#duplicate-keys
nhjjr commented 8 months ago

This problem happens when any problem occurs in the YAML document. It is probably a good idea to identify common problems and provide our own (more useful) errors, or if that fails capture the problem and report it as a generic "template-error" where --debug provides more useful information.

bpoldrack commented 7 months ago

@nhjjr : What would you regard as "more useful information"?

The error says exactly what's wrong and where from my POV. I don't know what's vague about it. This:

To suppress this check see: http://yaml.readthedocs.io/en/latest/api.html#duplicate-keys

is admittedly a bit annoying and would be nicer to just swallow, but other than that I don't know how to improve upon

in "/home/niels/code/onyo-demo/.onyo/templates/boardgame", line 2, column 1 found duplicate key "rating" with value "foo" (original value: "bar") in "/home/niels/code/onyo-demo/.onyo/templates/boardgame", line 3, column 1

nhjjr commented 7 months ago

The error itself is pretty clear, as it uses terminology consistently used in onyo and references the (problematic) file. The main problem is the advice on how to suppress the check. Not only is that impossible within the context of onyo, it would be unclear to someone not familiar with the code or the dependency being used and possibly allude to functionality within the API (that isn't actually there).

I should have been more clear about that.

bpoldrack commented 7 months ago

Ok. Agree on that aspect.