Skip to content

YAML syntax and indentation ​

Encyclopedia home · Search machine-readable catalog

The broken snippets are deliberate negative examples. Use only in an isolated fixture repository or lab.

F001 ​

Nested run key

Symptom. Parser or schema rejects steps.

Root cause. A step list was supplied as a mapping.

Broken example

yaml
steps:
  run: echo hello

Corrected example

yaml
steps:
  - run: echo hello

Verification. Validate that steps contains a single item and its log prints hello.

Correction validation syntax-validated.

F002 ​

Tab indentation

Symptom. scanner error near tab.

Root cause. A tab is illegal in indentation.

Broken example

yaml
jobs:
	test: {}

Corrected example

yaml
jobs:
  test: {}

Verification. Replace tabs with spaces, then complete the test job as in the syntax guide.

Correction validation syntax-validated.

F003 ​

Misaligned steps

Symptom. mapping values are not allowed here.

Root cause. steps must be a sibling of runs-on.

Broken example

yaml
sample:
  runs-on: ubuntu-latest
   steps: []

Corrected example

yaml
sample:
  runs-on: ubuntu-latest
  steps:
    - run: echo ok

Verification. Lint the workflow and inspect the sample job.

Correction validation syntax-validated.

F004 ​

Unquoted colon in a command

Symptom. mapping values are not allowed here.

Root cause. The colon is interpreted as a mapping separator.

Broken example

yaml
run: echo Check: passed

Corrected example

yaml
run: |
  echo 'Check: passed'

Verification. Confirm the step log prints Check: passed.

Correction validation syntax-validated.

F005 ​

Unclosed flow list

Symptom. expected comma or closing bracket.

Root cause. A closing bracket is missing.

Broken example

yaml
branches: [main, release

Corrected example

yaml
branches: [main, release]

Verification. Parse and verify two branch names.

Correction validation syntax-validated.

F006 ​

Duplicate job identifier

Symptom. one job disappears or lint rejects duplicate key.

Root cause. Duplicate keys can overwrite one job or be rejected.

Broken example

yaml
jobs:
  test: {runs-on: ubuntu-latest}
  test: {runs-on: windows-latest}

Corrected example

yaml
jobs:
  test-linux:
    runs-on: ubuntu-latest
    steps: [{run: echo linux}]
  test-windows:
    runs-on: windows-latest
    steps: [{run: echo windows}]

Verification. List both jobs in workflow UI.

Correction validation syntax-validated.

F007 ​

Unquoted glob

Symptom. alias parser error.

Root cause. Asterisk begins a YAML alias token.

Broken example

yaml
paths: [**/*.py]

Corrected example

yaml
paths: ["**/*.py"]

Verification. Change src/main.py and verify a run.

Correction validation syntax-validated.

F008 ​

Wrong boolean type

Symptom. unexpected string or incorrect behavior.

Root cause. A string was used where boolean or a typed expression is expected.

Broken example

yaml
continue-on-error: "false"

Corrected example

yaml
continue-on-error: false

Verification. Cause a deliberate failure and verify it blocks the run.

Correction validation syntax-validated.

F009 ​

Unindented here document in YAML

Symptom. yaml parsing fails before shell starts.

Root cause. YAML stripped indentation only from lines inside the block.

Broken example

yaml
run: |
  cat <<'FIXTURE'
body
FIXTURE

Corrected example

yaml
run: |
  cat <<'FIXTURE'
  body
  FIXTURE

Verification. Verify stdout contains body.

Correction validation syntax-validated.

F010 ​

Empty event mapped with an extra colon

Symptom. workflow config reports invalid event or never triggers.

Root cause. The event name accidentally contains a colon.

Broken example

yaml
on:
  push::
  workflow_dispatch:

Corrected example

yaml
on:
  push:
  workflow_dispatch:

Verification. Push and manually dispatch in a lab.

Correction validation syntax-validated.