Skip to content

ambiguous-booleans

GitHub ActionsYAMLsuspiciousfix: unsafedefault: offyaml/yamllint

Reports a plain yes, no, on, off, True, TRUE, False or FALSE (in the usual casings), which are booleans to a YAML 1.1 parser and strings to a YAML 1.2 parser. Lowercase true and false are not reported. The fix quotes the value and is unsafe.

The same file means two things: Python’s PyYAML reads no as false, while a YAML 1.2 parser reads it as the string "no". The classic failure is the country code NO (Norway) turning into false, and a key on turning into true.

To fix, quote the value to make it a string, or write true or false where a boolean is meant.

Reported
on: True
list: [FALSE, false, true]
? Yes
: y
After the fix
"on": "True"
list: ["FALSE", false, true]
? "Yes"
: y
github-actions:
lint:
rules:
ambiguous-booleans:
level: warn # off (default), warn, error
options:
check_keys: true
allowed: []
report_true_false: false
yaml:
lint:
rules:
ambiguous-booleans:
level: warn # off (default), warn, error
options:
check_keys: true
allowed: []
report_true_false: false
Option Type Default Description
check_keys bool true Also check mapping keys. Turn it off to keep GitHub workflow on:.
allowed list [] Spellings that are not reported, for example ["on"].
report_true_false bool false Also report true and false (unless listed in allowed), for code that wants every boolean quoted or spelled out.

Enabled by the presets: yaml/yamllint.

Suppress one line with sudsy-disable-next-line ambiguous-booleans in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
yamllint truthy full
yamllint truthy.allowed-values full
yamllint truthy.check-keys full