flashman
← All posts

YAML anchors and merge keys: debug CI config drift

Debug YAML anchor and merge-key surprises in CI configs by converting to JSON, diffing expanded jobs, and checking env inheritance safely before deploys.

2026-07-19 · 6 min read · Rahul Chitturi

  • yaml
  • ci
  • debugging

YAML anchors keep CI files compact, but they can also hide which values a job actually receives. A shared deploy template may merge environment variables, caches, or conditions in a way that looks obvious until one job overrides a nested field.

The result is usually a pipeline that behaves differently from the review diff: a missing secret name, a skipped test matrix, or a production deploy job inheriting staging settings.

Expand before you reason

When a CI job surprises you, stop reading only the compressed YAML. Convert or inspect the expanded representation so anchors, aliases, and merge keys become explicit values.

  • Check whether the platform supports YAML merge keys exactly as written
  • Confirm array values are replaced rather than deeply merged
  • Diff the expanded failing job against a known-good job
  • Mask secrets while preserving variable names and inheritance shape

Make shared config reviewable

Anchors are useful when the shared behavior is boring and stable. If reviewers need to mentally execute several merges to understand a deploy, split the risky values into named jobs or smaller templates.

Keep a minimal CI fixture for the failure. It should include the anchor, the job override, and the expanded output that proves what the runner will see.

A Flashman workflow

Use the YAML to JSON converter to make structure explicit, the JSON formatter to inspect nested values, and the diff tool to compare expanded job definitions.

Document whether the issue was anchor scope, merge-key support, array replacement, environment inheritance, or a platform-specific parser difference.

Try these tools