Find repeated keys and trace aliases to their anchors
Admin ·
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.
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.
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.
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.
primary: ®ion 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
- Keeping types when converting JSON and YAML
- Telling YAML comments apart from literal text
- Preserving CSV and TSV cells in YAML
- Keep repeated XML items ordered in YAML
- Format Service TOML and Keep Its Comments
- Find Duplicate TOML Keys and Version Errors
- Export Markdown Metadata and Heading Lines
- Format Nested Nginx Directives
- Find Nginx Structure Errors by Line
- Remove Nginx Comments and Preserve Values
- Check Kubernetes Metadata Keys and Values
- Keep INI Settings as Strings in YAML
- Keep Dotenv Values as Strings in YAML
- Trace GitHub Actions Job Dependencies
- Generate a GitHub Actions Workflow for Node.js
- Diagnose a GitLab Pipeline from Saved YAML
- Compare Stable YAML Before a Review
- Check an OpenAPI Markdown Reference
- Inspect Mixed HTML Content in YAML
- Find Dotenv Syntax Errors by Line
- Merge a YAML Overlay and Check Sequence Changes