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

Since 4.29, prunes header document while merging documents #1684

Open
antonincms opened this issue Jun 1, 2023 · 2 comments
Open

Since 4.29, prunes header document while merging documents #1684

antonincms opened this issue Jun 1, 2023 · 2 comments
Labels

Comments

@antonincms
Copy link

antonincms commented Jun 1, 2023

Describe the bug

Hello,

I constated that since YQ version v4.29.0 (precisely, it works with v4.28.2, do not work with 4.31.2 or latest, but I have other error when running v4.29.x or v4.30.x versions), it prunes my header comment while trying to merge documents using the command yq ea '. as $item ireduce ({}; . * $item )' .

Version of yq: 4.29.0 and above.
Operating system: mac or linux
Installed via: docker or binary

Input Yaml
Concise yaml document(s) (as simple as possible to show the bug, please keep it to 10 lines or less)
header.yml:

# **
# ** This file was automatically generated ...
# ** 
#

data.yml:

foo: bar

Command

This is working :

> docker run --rm -v "${PWD}":/workdir mikefarah/yq:4.28.2 ea '. as $item ireduce ({}; . * $item )' header.yaml data.yaml
# **
# ** This file was automatically generated ...
# **
foo: bar

Where this is not :

> docker run --rm -v "${PWD}":/workdir mikefarah/yq:4.31.2 ea '. as $item ireduce ({}; . * $item )' header.yaml data.yaml
foo: bar

I'm unsure wether this is a bug or expected behavior since 4.29.0, but as we used this feature to add headers to documents, if it is not a bug what would you suggest to do instead ?

@mikefarah
Copy link
Owner

That is a bug :/ - I'll need time to fix it up - but till then you could use this workaround - add an empty map to the file with the comment:

# **
# ** This file was automatically generated ...
# ** 
#
{}

@antonincms
Copy link
Author

If it is a bug we can wait for the fix, but thanks a lot for the workaround 👍

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

2 participants