YAML guides

Find repeated keys and trace aliases to their anchors

·

A configuration can be syntactically readable yet ambiguous because a map defines the same key twice. Following the key locations is more reliable than deciding which value a particular loader might keep.

YAML Validator

Find two spellings of the same key

Enter 0x10: first and 16: second on separate lines. Both keys are the integer sixteen under the YAML 1.2 core schema. The diagnostic identifies the repeated key and the first occurrence. Quoting "16" gives that key a string type.

YAML 1.2.2 specification

Trace the selected definition

Start with base: &color green and active: *color on separate lines. The report identifies one anchor and one alias. Define &color again before a later alias and the later reference points to the new binding. Insert a document separator before a reference and it needs a fresh definition.

YAML 1.2.2 specification

Trace a reused YAML setting

Validate this document and check the anchor and alias counts. The two entries share one defined value. This is a useful small test when a configuration works on its own but fails after several files are combined.

One anchor and one alias
primary: &region west
fallback: *region
  • Expect one document, one anchor and one alias. Rename the declaration to &zone without changing *region and validate again. Fix the mismatched name or define the anchor in the document where it is used.

Common questions

Does an empty stream have a document?

A stream containing only whitespace or comments has zero documents. An explicit document marker can introduce an empty document.

Does successful validation confirm a deployment configuration?

It confirms the supported YAML structure. Required service names, allowed settings and value ranges depend on the program reading the file.

Sources

Put it into practice.

Related guides