Description
Describe the bug
When evaluating a query, phantom blank lines are inserted into the result.
Note that any how to questions should be posted in the discussion board and not raised as an issue.
Version of yq: 4.45.4
Operating system: Linux
Installed via: releases binary
Input Yaml
Concise yaml document(s) (as simple as possible to show the bug, please keep it to 10 lines or less)
meh.yml:
env:
YQ_QUERY: >-
(.runs.steps // .jobs.*.steps) | map(
select(.uses | test("@(v\d+(\.\d+)*|\d+(\.\d+)+|[a-f0-9]{40})$") | not)
| .uses
| "\(key | line) \(split(\"@\")[1])"
)[]
Command
The command you ran:
yq .env.YQ_QUERY meh.yaml
Actual behavior
A blank line is inserted in the middle of and at the end variable value:
YQ_QUERY: >-
(.runs.steps // .jobs.*.steps) | map(
select(.uses | test("@(v\d+(\.\d+)*|\d+(\.\d+)+|[a-f0-9]{40})$") | not)
| .uses
| "\(key | line) \(split(\"@\")[1])"
)[]
Expected behavior
YQ_QUERY: >-
(.runs.steps // .jobs.*.steps) | map(
select(.uses | test("@(v\d+(\.\d+)*|\d+(\.\d+)+|[a-f0-9]{40})$") | not)
| .uses
| "\(key | line) \(split(\"@\")[1])"
)[]
Additional context
Add any other context about the problem here.
I thought maybe there was some weird/hidden character in the output, so I removed all the characters between map(
and select(
. This is the resulting YAML (`meh2.yaml):
env:
YQ_QUERY: >-
(.runs.steps // .jobs.*.steps) | map(select(.uses | test("@(v\d+(\.\d+)*|\d+(\.\d+)+|[a-f0-9]{40})$") | not)
| .uses
| "\(key | line) \(split(\"@\")[1])"
)[]
This is what yq .env meh2.yaml
returns now:
YQ_QUERY: >-
(.runs.steps // .jobs.*.steps) | map(select(.uses | test("@(v\d+(\.\d+)*|\d+(\.\d+)+|[a-f0-9]{40})$") | not)
| .uses
| "\(key | line) \(split(\"@\")[1])"
)[]
Notice the blank line in the middle of the result and at the end. So it seems unrelated to the data since a location that didn't have blank lines before spontaneously showed them.