hairyhenderson/gomplate

Suggestion: if there is a yaml parsing error, print which file produces the error

AndrewSav opened this issue · 3 comments

Currently I'm getting this wording:

08:19:37 ERR error="could not unmarshal templates as map or array: could not unmarshal templates as array: yaml: unmarshal errors:\n  line 2: cannot unmarshal !!map into []string"

Note it does not tell me in which file the error is happening. An improvement would be to include the file path into the error message so there is no guessing involved.

@AndrewSav can you post the full command/template(s)/datasource(s) that produced this? It's possible that the command doesn't give enough context to make the error clearer, but I can't know that unless I see more detail.

The simplest case is just gomplate and the yaml error is coming from .gomplate.yaml - this is the circumstances I came across it. In this situation, ostensibly you should be able to figure out that it's from .gomplate.yaml since there is nothing else. But you also could have .yaml datasource and this is when it starting becoming even more confusing.

This particular error is produced by the following .gomplate.yaml :

templates:
  dir: /foo/bar

Please let me know if anything is still unclear.

Sorry for the delay...

Thanks for the detail - the YAML in question is the config rather than what I assumed was a datasource.

The error message could definitely be clearer!