geofffranks / spruce

A BOSH template merge tool
MIT License
433 stars 78 forks source link

on -> true #337

Closed cjyar closed 3 years ago

cjyar commented 3 years ago

It seems like spruce is trying to interpret the key name as a boolean. This causes problems when processing YAML for GitHub Actions, where on is a top level element of the file.

$ echo on: | spruce merge
true: null
geofffranks commented 3 years ago

This is a function of the yaml spec. https://yaml.org/type/bool.html Does github handle it properly if you quote the key?

echo '"on":' | spruce merge
cjyar commented 3 years ago

Thanks for setting me straight! YAML is more complicated than it looks.

GitHub parsing doesn't seem to believe that on and true mean the same thing, in the context of a YAML key. I tried these combinations in a GitHub Actions file:

As far as Spruce's parsing, here's what I see providing the same things to spruce merge:

So it seems like a workaround would be to double quote on, as you suggested. (Or the verbose and explicit !!str on might work?)

Still, I wonder if it's a bug in somebody's YAML parsing. 1.0.3.2 for the core schema doesn't say anything about on or off, but the link you gave for the bool datatype sort of implies otherwise. Should Spruce and GitHub parse a scalar on using the same tag?

geofffranks commented 3 years ago

closing as stale