Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explode with merge aliases throw an error #2178

Open
jfrz38 opened this issue Oct 23, 2024 · 0 comments
Open

Explode with merge aliases throw an error #2178

jfrz38 opened this issue Oct 23, 2024 · 0 comments
Labels

Comments

@jfrz38
Copy link

jfrz38 commented Oct 23, 2024

Describe the bug
I'm trying to work with anchors and alias operators but I'm getting an error merge anchor only supports maps, got !!seq instead while I'm exploding the yaml.

It seems the line - <<: *my-anchor is the problem since I can work without that line but if it exists then throw the error.

Docs say

yq supports merge aliases (like <<: *blah) ...

So I didn't expected the error.

Version of yq: 4.44.3
Operating system: linux
Installed via: binary release

Input Yaml

level_1:
- name: one
  level_2: &my-anchor
    - name: one_v1
      level_3:
        - name: foo
- name: two
  level_2:
    - <<: *my-anchor # uses my-anchor configuration
    - name: one_v1
      level_3: # add level_3.name: bar to my-anchor
        - name: bar

Command

yq 'explode(.)' data1.yml

Actual behavior

It throws an error:

Error: merge anchor only supports maps, got !!seq instead

Expected behavior

Just expand yaml and generate something like this:

---
level_1:
  - name: one
    level_2:
      - name: one_v1
        level_3:
          - name: foo
  - name: two
    level_2:
      - name: one_v1 # this is the anchor property
        level_3:
          - name: foo
      - name: one_v1
        level_3:
          - name: bar

I've tried using other linters but format seems ok and could be possible to expand.
Also I've tried to expand without - <<: *my-anchor line and not throw an error and I've run yq '.level_1[0] | explode(.)' data1.yml and also works fine. So problem seems to be the definition - <<: *my-anchor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants
@jfrz38 and others