Our checkout service reads the list of countries we deliver to from a JSON file, and Ansible writes that file from a list in group_vars. In October we started delivering to Norway. The change was one line, NO added to the list between DK and SE, it passed review and it went out on a Tuesday. A week later the commercial team asked why Norway had produced no orders at all, when the launch email had gone to eleven thousand customers there.
Norwegian customers had been told at the first step of checkout that we did not deliver to their country. The JSON file on the servers said why. The list read "DK", false, "SE".
Ansible parses its variables files with PyYAML, which follows YAML 1.1. In YAML 1.1 an unquoted yes, no, on or off, in lower case, capitalised or in capitals, is a boolean. So NO was never the string NO. It was the value false from the moment the file was read, and the to_json filter in our template wrote it out faithfully as false. The country code for Norway is the most famous case of this, and we still had not thought of it, because the other twenty two codes in the list were plain strings and YAML had no opinion about them.
Nothing complained. The template rendered, the JSON was valid, and the checkout service loaded a list that happened to contain one boolean. It checked whether the customer's country was in the list, the string NO was not, and every Norwegian customer got the polite refusal we had written for countries we do not serve.
Every element of the list is quoted now, and so is every string in our variables files that is a code rather than prose. yamllint runs in the pipeline with the truthy rule, which allows only true and false and rejects the other spellings, and it found two more in other roles, a feature flag written as on and a storage tier called OFF. The template asserts that every country is a two letter string before it writes the file, and the checkout service refuses to start with a list it cannot read as strings.
YAML decided what NO meant before any of our code saw it. A list of country codes is a list of strings only if somebody says so.
– Sergey Shinder

