Skip to content
Novus Examples
yml720 B

GitHub Actions on: Key YAML Boolean Trap

The workflow file that exposes the YAML 1.1 boolean resolver: a bare `on` key becomes True in PyYAML, SnakeYAML and Psych, so a round-trip through those loaders loses the trigger block. The env values repeat the trap with NO, yes and off alongside a quoted control.

Preview — first 26 linesyml
# The `on:` key is the single most famous YAML-in-CI trap. Under the YAML 1.1 resolver
# (PyYAML, SnakeYAML's default, Ruby Psych) the bare word `on` is a BOOLEAN, so a round-trip
# through such a loader turns this document's trigger block into the key `True`. YAML 1.2's
# core schema resolves only true/false, and keeps `on` as a string.
name: Norway-adjacent trigger keys

on:
  schedule:
    - cron: "0 3 * * 1"
  workflow_dispatch:

permissions:
  contents: read

jobs:
  probe:
    runs-on: ubuntu-latest
    steps:
      - name: Values that YAML 1.1 also coerces
        run: echo "see the env block"
        env:
          NORWAY: NO
          YES_WORD: yes
          OFF_WORD: off
          QUOTED_NORWAY: "NO"

Specifications

System
GitHub Actions
Edge Case
bare `on` resolves to boolean true under YAML 1.1
Yaml11 Key
True
Yaml12 Key
on
Also Coerced
NO, yes, off

Testing contract

Expected to recover
Scenario
Load a GitHub Actions workflow and look up its trigger block by the key `on`
Expected result
A YAML 1.1 loader yields the boolean key True and the lookup misses; a YAML 1.2 core-schema loader yields the string key "on"

What is a .yml file?

YML is an alternate file extension for YAML, a human-readable data-serialization format based on indentation, key-value mappings, and lists. The content and parsing rules are identical to .yaml; only the extension differs. It is widely used for CI and application configuration files.

How to use this file

Use an example YML file to test that config loaders treat .yml and .yaml identically, and to exercise indentation, comment, and multi-document parsing.

How to use this file for testing

“GitHub Actions on: Key YAML Boolean Trap” is a deterministic Novus Examples fixture for Config parsing, Encoding detection, Editor testing. TOML and INI configuration files with nested sections and typed values — for testing config parsers and loaders.

Documented properties for this file: YML · 720 bytes. Compare results against paired or grouped companions on this page when present (clean↔damaged, searchable↔scanned, or format twins) so scores stay reproducible across runs.

Download the file once, keep the path stable in CI or local scripts, and treat the spec table as the contract: dimensions, seeds, field lists, and roles are intentional. Corrupt or invalid samples are labelled as such — expect parsers to fail loudly rather than silently accept them.

Pipeline and infrastructure fixtures are inert configuration: steps reference fictional images and scripts, and nothing here executes. Run your linter, schema validator, migrator, or policy engine against them, and expect the deprecated-syntax and intentionally invalid variants to be rejected.

Point your config loader at the file and assert it reads the documented sections and typed values, including any deliberately-tricky nesting or comments.

Code examples

import yaml  # pip install pyyaml

with open("on-key-yaml-1-1.yml") as f:
    data = yaml.safe_load(f)
print(data)

Generated by generation/pipelines.py. Free for any use, no attribution required — license.