#2851·yq

flatten does not resolve anchored lists

Author: esahin90Created Sep 2, 2026Updated Sep 2, 2026
Labelsbugv4

Describe the bug When using yaml anchors I expected, that the anchors are resolved first, before evaluating the flatten function, but unfortunately this is not the case.

Version of yq: 4.53.2 Operating system: NixOS 26.05 Installed via: nix

Input Yaml

test.yaml

yaml
base_list: &base
  - item1
  - item2

extended_list:
  - *base
  - item3

Command

yq ".extended_list | flatten" < test.yaml

Actual behaviour

yaml
- *base
- item3

Expected behaviour

yaml
- item1
- item2
- item3

Additional context only if I select json as an output, the anchor is resolved, but flatten still fails to flatten the output and it looks like, flatten has no effect.

$ /nix/store/lvpr8f270g3y87ziznad39gmcqllikm5-yq-go-4.53.2/bin/yq ".extended_list | flatten" -o json < test.yaml
[
  [
    "item1",
    "item2"
  ],
  "item3"
]